#include <scheduler.h>
Public Methods | |
| Scheduler () | |
| ~Scheduler () | |
| void | ReadyToRun (Thread *thread) |
| Thread * | FindNextToRun () |
| void | Run (Thread *nextThread) |
| void | Print () |
Private Attributes | |
| List * | readyList |
|
|
Definition at line 30 of file scheduler.cc. References readyList.
|
|
|
Definition at line 40 of file scheduler.cc. References readyList.
00041 {
00042 delete readyList;
00043 }
|
|
|
Definition at line 71 of file scheduler.cc. References readyList, and List::Remove.
|
|
|
Definition at line 143 of file scheduler.cc. References List::Mapcar, readyList, and VoidFunctionPtr.
00144 {
00145 printf("Ready list contents:\n");
00146 readyList->Mapcar((VoidFunctionPtr) ThreadPrint);
00147 }
|
|
|
Definition at line 54 of file scheduler.cc. References List::Append, DEBUG, Thread::getName, READY, readyList, and Thread::setStatus.
|
|
|
Definition at line 91 of file scheduler.cc. References Thread::CheckOverflow, DEBUG, Thread::getName, NULL, RUNNING, Thread::setStatus, and SWITCH.
00092 {
00093 Thread *oldThread = currentThread;
00094
00095 #ifdef USER_PROGRAM // ignore until running user programs
00096 if (currentThread->space != NULL) { // if this thread is a user program,
00097 currentThread->SaveUserState(); // save the user's CPU registers
00098 currentThread->space->SaveState();
00099 }
00100 #endif
00101
00102 oldThread->CheckOverflow(); // check if the old thread
00103 // had an undetected stack overflow
00104
00105 currentThread = nextThread; // switch to the next thread
00106 currentThread->setStatus(RUNNING); // nextThread is now running
00107
00108 DEBUG('t', "Switching from thread \"%s\" to thread \"%s\"\n",
00109 oldThread->getName(), nextThread->getName());
00110
00111 // This is a machine-dependent assembly language routine defined
00112 // in switch.s. You may have to think
00113 // a bit to figure out what happens after this, both from the point
00114 // of view of the thread and from the perspective of the "outside world".
00115
00116 SWITCH(oldThread, nextThread);
00117
00118 DEBUG('t', "Now in thread \"%s\"\n", currentThread->getName());
00119
00120 // If the old thread gave up the processor because it was finishing,
00121 // we need to delete its carcass. Note we cannot delete the thread
00122 // before now (for example, in Thread::Finish()), because up to this
00123 // point, we were still running on the old thread's stack!
00124 if (threadToBeDestroyed != NULL) {
00125 delete threadToBeDestroyed;
00126 threadToBeDestroyed = NULL;
00127 }
00128
00129 #ifdef USER_PROGRAM
00130 if (currentThread->space != NULL) { // if there is an address space
00131 currentThread->RestoreUserState(); // to restore, do it.
00132 currentThread->space->RestoreState();
00133 }
00134 #endif
00135 }
|
|
|
Definition at line 32 of file scheduler.h. Referenced by FindNextToRun, Print, ReadyToRun, Scheduler, and ~Scheduler. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002