00001 /* #start# *********************************************************** 00002 00003 Scheduling Simulator 00004 Lehrstuhl f"ur Effiziente Algorithmen 00005 Technische Universit"at M"unchen 00006 00007 File : $Id: SPassiveMachines.h,v 1.8 2003/03/24 10:39:25 meierb Exp $ 00008 00009 Purpose : base class for all kind of resources. "normal" machines 00010 are derived from this class. passive machines cannot 00011 process jobs, but in all other respects they are identical 00012 to "normal" machines 00013 00014 RCS-Log: 00015 $Log: SPassiveMachines.h,v $ 00016 Revision 1.8 2003/03/24 10:39:25 meierb 00017 minor changes to make chekced-in algorithms work. 00018 still not perfect because problems exist with SAlexTest.cpp & const 00019 00020 Revision 1.2 2003/01/20 14:46:13 meierb 00021 new algorithms Weiss/LDM/PDM are working now 00022 00023 Revision 1.1.1.1 2002/12/02 22:26:19 meierb 00024 my_schedule 00025 00026 Revision 1.3 2002/11/13 19:27:59 taeubig 00027 Adaptations for (leda_)dic_item 00028 00029 Revision 1.2 2002/11/11 16:52:52 taeubig 00030 header include changes 00031 00032 Revision 1.1 2002/08/29 12:59:58 taeubig 00033 Added the sources 00034 00035 Revision 1.23 2001/05/16 13:19:57 taeubig 00036 QT headers are included last because of "slots" conflict 00037 00038 Revision 1.22 2000/05/29 19:54:11 taeubig 00039 New subdirectory structure 00040 00041 Revision 1.21 2000/05/29 14:01:29 taeubig 00042 Added SComplexPosition 00043 00044 Revision 1.20 2000/05/24 12:46:14 taeubig 00045 New compiler (gcc-2.95) and new Qt (2.1) 00046 Replaced "list" by "leda_list" etc. 00047 00048 Revision 1.19 2000/01/17 17:38:09 zoidl 00049 added javadoc comments 00050 00051 Revision 1.18 2000/01/07 12:28:12 zoidl 00052 getTopology() returns no "const" anymore 00053 00054 Revision 1.17 1999/11/24 12:20:59 taeubig 00055 getFreePos() no longer returns a reference 00056 00057 Revision 1.16 1999/11/16 14:46:55 schickin 00058 reset()-bug in environment and machines removed 00059 00060 Revision 1.15 1999/11/03 02:52:58 taeubig 00061 canEmbedAt function (any other ideas?) 00062 00063 Revision 1.14 1999/10/29 10:46:42 schickin 00064 line topology (between mesh and single-top.) added 00065 00066 Revision 1.13 1999/10/27 12:57:33 schickin 00067 bug SJob::reset() removed, simTime-Handling and parsing of doubles changed 00068 00069 Revision 1.12 1999/08/05 13:02:58 schickin 00070 redesign: event list for algorithm is generated by logger now 00071 00072 Revision 1.11 1999/08/05 08:48:07 schickin 00073 purpose of important classes noted in the header-files 00074 00075 Revision 1.10 1999/06/17 16:34:37 hall 00076 STopology changed, tuned STSysSchedEvent-stuff and lost more! 00077 00078 Revision 1.9 1999/04/27 13:39:30 schickin 00079 well folks, that's the first demo version that really runs 8-) 00080 00081 Revision 1.8 1999/04/23 15:31:24 schickin 00082 sync with sunhalle 00083 00084 Revision 1.7 1999/03/25 14:12:48 schickin 00085 several changes in /model (no real executable yet) 00086 00087 Revision 1.6 1999/03/23 14:26:47 schickin 00088 a lot of new code in /model: things compile but have no functionality 00089 00090 Revision 1.5 1999/02/10 15:05:46 schickin 00091 model-directory can be compiled now 00092 00093 Revision 1.4 1999/02/10 10:50:46 schickin 00094 main loop for simulation added 00095 00096 Revision 1.3 1999/01/29 10:03:44 schickin 00097 Project-Headers added. 00098 00099 00100 * #end# ************************************************************* */ 00101 00102 #ifndef SPASSIVEMACHINES_H 00103 #define SPASSIVEMACHINES_H 00104 00105 // system header files 00106 #include <LEDA/list.h> 00107 #include <LEDA/array.h> 00108 #define LEDA_STL_ITERATORS 00109 #include <LEDA/dictionary.h> 00110 #undef LEDA_STL_ITERATORS 00111 00112 #ifndef leda_dic_item 00113 #if __LEDA__ < 440 00114 #define leda_dic_item dic_item 00115 #else 00116 #define leda_dic_item leda::dic_item 00117 #endif 00118 #endif 00119 00120 // project header files 00121 #include "STaskSystem.h" 00122 #include "SJobExecInfo.h" 00123 #include "SPassiveMachinesMod.h" 00124 #include "STSysSchedEvent.h" 00125 #include "jobs/SJob.h" 00126 #include "topos/STopology.h" 00127 #include "../general/SObservable.h" 00128 00129 class SPassiveMachinesMod; 00130 00131 class SJob; 00132 00142 class SPassiveMachines : public SObservable { 00143 friend class SPassiveMachinesMod; 00144 public: 00145 00146 typedef leda_dictionary<int, SJobExecInfo*> MapJobToInfo; 00147 00150 SPassiveMachines(); 00153 virtual ~SPassiveMachines(); 00154 00155 // copying is not implemented because SPassiveMachines owns the job info 00156 SPassiveMachines& operator=(SPassiveMachines&); 00157 00161 void reset(); 00162 00166 STopology& getTopology() const { return *_pTop; }; 00167 00172 bool isAllocated(const SJob& job) const; 00174 bool isMachFree(int pos); 00175 00178 const leda_set<SJob*> &getAllocatedJobs() const { return _allocatedJobs; }; 00179 00184 int getPos(const SJob& job) const { return _pTop->getPos(job.getIndex()); }; 00185 00187 double getStartOfAlloc(const SJob& job) const; 00188 00192 leda_list<int> getFreeMachines() const { return _pTop->getFreePos(); }; 00193 00199 bool canEmbedAt(const STopology &top, int pos) const { return _pTop->canEmbedAt(top, pos); }; 00200 00208 virtual void allocate(SJob& job, int pos = -1); 00209 virtual void allocate(SJob& job, SComplexPosition* pComplexPos = NULL); 00210 00214 virtual void deallocate(SJob& job); 00215 00223 virtual void simulate(double oldTime, double newTime) {}; 00224 00232 virtual double getNextEventTime(double currTime) const { return MAXDOUBLE; }; 00233 00236 virtual SPassiveMachinesMod& getModifier() 00237 { return _mod; }; 00238 00239 00240 private: 00243 void clearJobInfo(); 00244 SPassiveMachinesMod _mod; 00247 STopology * _pTop; 00249 MapJobToInfo _jobToInfo; 00251 leda_set<SJob*> _allocatedJobs; 00252 protected: 00253 // SMachines needs access to those member variables but no one else 00254 STaskSystem* _pTaskSys; 00255 00258 SJobExecInfo &getInfo(const SJob &job) 00259 { return *_jobToInfo.access(job.getIndex()); }; 00260 00263 const SJobExecInfo &getInfo(const SJob &job) const 00264 { return *_jobToInfo.access(job.getIndex()); }; 00265 }; 00266 00267 #endif //SPASSIVEMACHINES_H 00268 00269 00270 00271 00272 00273