#include <scheduler.h>
Inheritance diagram for Scheduler:


Definition at line 79 of file scheduler.h.
Public Member Functions | |
| virtual void | cancel (Event *)=0 |
| double | clock () const |
| virtual Event * | deque ()=0 |
| virtual const Event * | head ()=0 |
| virtual void | insert (Event *)=0 |
| virtual Event * | lookup (scheduler_uid_t uid)=0 |
| virtual void | reset () |
| virtual void | run () |
| void | schedule (Handler *, Event *, double delay) |
| virtual double | start () |
| virtual void | sync () |
Static Public Member Functions | |
| static Scheduler & | instance () |
Protected Member Functions | |
| int | command (int argc, const char *const *argv) |
| void | dispatch (Event *, double) |
| void | dispatch (Event *) |
| void | dumpq () |
| Scheduler () | |
| virtual | ~Scheduler () |
Protected Attributes | |
| double | clock_ |
| int | halted_ |
Static Protected Attributes | |
| static Scheduler * | instance_ |
| static scheduler_uid_t | uid_ = 1 |
|
|
Definition at line 63 of file scheduler.cc. 00063 : clock_(SCHED_START), halted_(0) 00064 { 00065 }
|
|
|
Definition at line 67 of file scheduler.cc. References instance_. 00067 { 00068 instance_ = NULL ; 00069 }
|
|
|
|
||||||||||||
|
Definition at line 189 of file scheduler.cc. References at_handler, cancel(), clock(), MemTrace::diff(), dumpq(), halted_, instance_, lookup(), AtEvent::proc_, reset(), run(), schedule(), STRTOUID, Event::uid_, and UID_PRINTF_FORMAT. 00190 { 00191 Tcl& tcl = Tcl::instance(); 00192 if (instance_ == 0) 00193 instance_ = this; 00194 if (argc == 2) { 00195 if (strcmp(argv[1], "run") == 0) { 00196 /* set global to 0 before calling object reset methods */ 00197 reset(); // sets clock to zero 00198 run(); 00199 return (TCL_OK); 00200 } else if (strcmp(argv[1], "now") == 0) { 00201 sprintf(tcl.buffer(), "%.17g", clock()); 00202 tcl.result(tcl.buffer()); 00203 return (TCL_OK); 00204 } else if (strcmp(argv[1], "resume") == 0) { 00205 halted_ = 0; 00206 run(); 00207 return (TCL_OK); 00208 } else if (strcmp(argv[1], "halt") == 0) { 00209 halted_ = 1; 00210 return (TCL_OK); 00211 00212 } else if (strcmp(argv[1], "clearMemTrace") == 0) { 00213 #ifdef MEMDEBUG_SIMULATIONS 00214 extern MemTrace *globalMemTrace; 00215 if (globalMemTrace) 00216 globalMemTrace->diff("Sim."); 00217 #endif 00218 return (TCL_OK); 00219 } else if (strcmp(argv[1], "is-running") == 0) { 00220 sprintf(tcl.buffer(), "%d", !halted_); 00221 return (TCL_OK); 00222 } else if (strcmp(argv[1], "dumpq") == 0) { 00223 if (!halted_) { 00224 fprintf(stderr, "Scheduler: dumpq only allowed while halted\n"); 00225 tcl.result("0"); 00226 return (TCL_ERROR); 00227 } 00228 dumpq(); 00229 return (TCL_OK); 00230 } 00231 } else if (argc == 3) { 00232 if (strcmp(argv[1], "at") == 0 || 00233 strcmp(argv[1], "cancel") == 0) { 00234 Event* p = lookup(STRTOUID(argv[2])); 00235 if (p != 0) { 00236 /*XXX make sure it really is an atevent*/ 00237 cancel(p); 00238 AtEvent* ae = (AtEvent*)p; 00239 delete ae; 00240 } 00241 } else if (strcmp(argv[1], "at-now") == 0) { 00242 const char* proc = argv[2]; 00243 00244 // "at [$ns now]" may not work because of tcl's 00245 // string number resolution 00246 AtEvent* e = new AtEvent; 00247 int n = strlen(proc); 00248 e->proc_ = new char[n + 1]; 00249 strcpy(e->proc_, proc); 00250 schedule(&at_handler, e, 0); 00251 sprintf(tcl.buffer(), UID_PRINTF_FORMAT, e->uid_); 00252 tcl.result(tcl.buffer()); 00253 } 00254 return (TCL_OK); 00255 } else if (argc == 4) { 00256 if (strcmp(argv[1], "at") == 0) { 00257 /* t < 0 means relative time: delay = -t */ 00258 double delay, t = atof(argv[2]); 00259 const char* proc = argv[3]; 00260 00261 AtEvent* e = new AtEvent; 00262 int n = strlen(proc); 00263 e->proc_ = new char[n + 1]; 00264 strcpy(e->proc_, proc); 00265 delay = (t < 0) ? -t : t - clock(); 00266 if (delay < 0) { 00267 tcl.result("can't schedule command in past"); 00268 return (TCL_ERROR); 00269 } 00270 schedule(&at_handler, e, delay); 00271 sprintf(tcl.buffer(), UID_PRINTF_FORMAT, e->uid_); 00272 tcl.result(tcl.buffer()); 00273 return (TCL_OK); 00274 } 00275 } 00276 return (TclObject::command(argc, argv)); 00277 }
Here is the call graph for this function: ![]() |
|
|
Implemented in ListScheduler, HeapScheduler, CalendarScheduler, and SplayScheduler. |
|
||||||||||||
|
Definition at line 141 of file scheduler.cc. References abort(), clock_, Handler::handle(), Event::handler_, and Event::uid_. 00142 { 00143 if (t < clock_) { 00144 fprintf(stderr, "ns: scheduler going backwards in time from %f to %f.\n", clock_, t); 00145 abort(); 00146 } 00147 00148 clock_ = t; 00149 p->uid_ = -p->uid_; // being dispatched 00150 p->handler_->handle(p); // dispatch 00151 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 154 of file scheduler.cc. References Event::time_. Referenced by RealTimeScheduler::run(), and run().
|
|
|
Definition at line 280 of file scheduler.cc. References clock(), deque(), Event::handler_, Event::time_, Event::uid_, and UID_PRINTF_FORMAT. Referenced by command(). 00281 { 00282 Event *p; 00283 00284 printf("Contents of scheduler queue (events) [cur time: %f]---\n", 00285 clock()); 00286 while ((p = deque()) != NULL) { 00287 printf("t:%f uid: ", p->time_); 00288 printf(UID_PRINTF_FORMAT, p->uid_); 00289 printf(" handler: %p\n", p->handler_); 00290 } 00291 }
Here is the call graph for this function: ![]() |
|
|
Implemented in ListScheduler, HeapScheduler, CalendarScheduler, and SplayScheduler. |
|
|
Implemented in ListScheduler, HeapScheduler, CalendarScheduler, and SplayScheduler. Referenced by schedule(). |
|
|
|
Implemented in ListScheduler, HeapScheduler, CalendarScheduler, and SplayScheduler. Referenced by command(), and SemanticPacketQueue::filterAcks(). |
|
|
Reimplemented in RealTimeScheduler. Definition at line 183 of file scheduler.cc. References clock_, and SCHED_START. Referenced by command(). 00184 { 00185 clock_ = SCHED_START; 00186 }
|
|
|
Reimplemented in RealTimeScheduler. Definition at line 119 of file scheduler.cc. References deque(), dispatch(), halted_, instance_, and Event::time_. Referenced by command(). 00120 { 00121 instance_ = this; 00122 Event *p; 00123 /* 00124 * The order is significant: if halted_ is checked later, 00125 * event p could be lost when the simulator resumes. 00126 * Patch by Thomas Kaemer <Thomas.Kaemer@eas.iis.fhg.de>. 00127 */ 00128 while (!halted_ && (p = deque())) { 00129 dispatch(p, p->time_); 00130 } 00131 }
Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
|
Definition at line 95 of file scheduler.h. References SCHED_START. 00095 { // start time 00096 return SCHED_START; 00097 }
|
|
|
Reimplemented in RealTimeScheduler. Definition at line 94 of file scheduler.h. Referenced by TapAgent::dispatch().
|
|
|
Definition at line 106 of file scheduler.h. Referenced by clock(), dispatch(), RealTimeScheduler::reset(), reset(), RealTimeScheduler::run(), schedule(), and RealTimeScheduler::sync(). |
|
|
Definition at line 107 of file scheduler.h. Referenced by command(), RealTimeScheduler::run(), and run(). |
|
|
Definition at line 108 of file scheduler.h. Referenced by command(), instance(), RealTimeScheduler::run(), run(), and ~Scheduler(). |
|
|
Definition at line 109 of file scheduler.h. Referenced by schedule(). |
1.4.6