Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

cosyrte.cc

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  *
00003  * (C) Copyright Koninklijke Philips Electronics NV 2006. 
00004  * All rights reserved. This software is licensed under the terms of
00005  * version 2.1 of the GNU Lesser General Public License as published 
00006  * by the Free Software Foundation. For licensing and warranty
00007  * information, see the file COPYING in the main directory.
00008  *
00009  *------------------------------------------------------------------*/
00010 
00011 #include "rte.h"
00012 #include "cosynetwork.h"
00013 #include "cosyprocess.h"
00014 #include "cosyfifo.h"
00015 #include "cosyselect.h"
00016 #include "check.h"
00017 #include "network.h"
00018 #include <stdlib.h>
00019 #include <iostream>
00020 
00021 /*----------------------------------------------------------------------------*/
00022 
00023 rteNetwork* cosyRte::create(NetworkImpl& n)
00024 {
00025 #ifdef PREEMPTIVE
00026   lock();   // enter critical section
00027 #endif
00028         rteNetwork* r = new cosyNetwork(n,*os, *this);
00029 #ifdef PREEMPTIVE
00030   unlock(); // leave critical section
00031 #endif
00032   return r;
00033 }
00034 
00035 /*----------------------------------------------------------------------------*/
00036 
00037 rteProcess* cosyRte::create(ProcessImpl& p)
00038 {
00039 #ifdef PREEMPTIVE
00040   lock();   // enter critical section
00041 #endif
00042         rteProcess* r = new cosyProcess(p, *this);
00043 #ifdef PREEMPTIVE
00044   unlock(); // leave critical section
00045 #endif
00046   return r;
00047 }
00048 
00049 /*----------------------------------------------------------------------------*/
00050 
00051 rteFifo* cosyRte::create(FifoImpl& f)
00052 {
00053 #ifdef PREEMPTIVE
00054   lock();   // enter critical section
00055 #endif
00056         rteFifo* r = new cosyFifo(f, *this);
00057 #ifdef PREEMPTIVE
00058   unlock(); // leave critical section
00059 #endif
00060   return r;
00061 }
00062 
00063 /*----------------------------------------------------------------------------*/
00064 
00065 rteSelect* cosyRte::create(SelectImpl& s)
00066 {
00067 #ifdef PREEMPTIVE
00068   lock();   // enter critical section
00069 #endif
00070         rteSelect* r = new cosySelect(s, *this);
00071 #ifdef PREEMPTIVE
00072   unlock(); // leave critical section
00073 #endif
00074   return r;
00075 }
00076 
00077 /*----------------------------------------------------------------------------*/
00078 
00079 #ifdef PREEMPTIVE
00080 void cosyRte::lock()
00081 {
00082   mutex.lock();
00083 }
00084 
00085 /*----------------------------------------------------------------------------*/
00086 
00087 void cosyRte::unlock()
00088 {
00089   mutex.unlock();
00090 }
00091 #endif
00092 
00093 /*----------------------------------------------------------------------------*/
00094 
00095 cosyRte::cosyRte() : 
00096   Rte(),
00097   os(boot())
00098 {
00099   outStream = &std::cout;
00100   errStream = &std::cerr;
00101   inStream  = &std::cin;
00102 }
00103 
00104 /*----------------------------------------------------------------------------*/
00105 
00106 cosyRte::~cosyRte()
00107 { 
00108   delete os;
00109 }
00110 
00111 /*----------------------------------------------------------------------------*/
00112 
00113 void cosyRte::start(ProcessNetwork& n)
00114 {
00115   if (check(&(NetworkBase&)n, cerr()) != 0)
00116     exit(1);
00117 
00118   rteNetwork* net = create((NetworkImpl&)n);
00119 
00120   net->start();
00121   net->api()->compWorkload->clean();
00122   net->api()->commWorkload->clean();
00123   ((cosyNetwork*)net)->printComputationWorkload();
00124   ((cosyNetwork*)net)->printCommunicationWorkload();
00125   
00126   delete net;
00127 }
00128 
00129 /*----------------------------------------------------------------------------*/
00130 
00131 Rte* newRte() {
00132   return new cosyRte();
00133 }
00134 
00135 /*----------------------------------------------------------------------------*/
00136 
00137 void start(ProcessNetwork& n) {
00138 
00139   cosyRte* rte = new cosyRte();
00140         rte->start(n);
00141   delete rte;
00142 }
00143 

Generated on Wed Feb 15 14:52:38 2006 for yapi by doxygen 1.3.2