Main Page | Alphabetical List | Class List | File List | Class Members | File Members

Scheduler Class Reference

#include <scheduler.h>

List of all members.

Public Member Functions

 Scheduler ()
 ~Scheduler ()
void ReadyToRun (Thread *thread)
ThreadFindNextToRun ()
void Print ()
int IsEmpty ()

Static Public Member Functions

void timerIntH (int sig)


Constructor & Destructor Documentation

Scheduler::Scheduler  ) 
 

Definition at line 55 of file scheduler.cc.

00056 { 00057 readyList = new List; 00058 }

Scheduler::~Scheduler  ) 
 

Definition at line 65 of file scheduler.cc.

00066 { 00067 delete readyList; 00068 }


Member Function Documentation

Thread * Scheduler::FindNextToRun  ) 
 

Definition at line 96 of file scheduler.cc.

References List::Remove().

Referenced by schedule().

00097 { 00098 return (Thread *)readyList->Remove(); 00099 }

int Scheduler::IsEmpty  ) 
 

Definition at line 70 of file scheduler.cc.

References List::IsEmpty().

Referenced by main(), Thread::Suspend(), and timerIntH().

00071 { 00072 return readyList->IsEmpty(); // default*/ 00073 }

void Scheduler::Print  ) 
 

Definition at line 108 of file scheduler.cc.

References List::Mapcar(), ThreadPrint(), and VoidFunctionPtr.

00109 { 00110 printf("Ready list contents:\n"); 00111 readyList->Mapcar((VoidFunctionPtr) ThreadPrint); 00112 }

void Scheduler::ReadyToRun Thread thread  ) 
 

Definition at line 83 of file scheduler.cc.

References List::Append(), READY, and Thread::setStatus().

Referenced by Thread::Fork(), schedule(), and Semaphore::V().

00084 { 00085 thread->setStatus(READY); 00086 readyList->Append((void *)thread); 00087 }

void Scheduler::timerIntH int  sig  )  [static]
 

Definition at line 120 of file scheduler.cc.

References Thread::cbuff, currentThread, interrupt, IntOff, IsEmpty(), Interrupt::level, preempt, PREEMPTION, schedule(), scheduler, secCount, TICKS_PER_SEC, timer_id, timer_value, timerCount, and Interrupt::YieldOnReturn().

00121 { 00122 static int counter = 0; 00123 00124 if (!PREEMPTION && !preempt) 00125 return; 00126 00127 timerCount++; 00128 counter++; 00129 if (counter == TICKS_PER_SEC) // the timer should be called about 15 times per second 00130 { 00131 counter = 0; 00132 secCount++; // increment the elapsed seconds 00133 } 00134 // arm the timer again 00135 timer_settime(timer_id, 0, &timer_value, 0); 00136 00137 00138 if (interrupt->level == IntOff || scheduler->IsEmpty()) 00139 { 00140 if (interrupt->level == IntOff) // preempt this thread after the sys call is done 00141 { 00142 interrupt->YieldOnReturn(); 00143 } 00144 return; 00145 } 00146 00147 if (currentThread) 00148 { 00149 if (sigsetjmp(currentThread->cbuff, 1) == 0) 00150 schedule(); 00151 } 00152 else // just call schedule as nothing is running at the moment besides the main proc 00153 schedule(); 00154 00155 return; 00156 }


The documentation for this class was generated from the following files:
Generated on Thu Sep 16 12:33:49 2004 for NachOS by doxygen 1.3.8