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

Scheduler Class Reference

The following class defines the scheduler/dispatcher abstraction -- the data structures and operations needed to keep track of which thread is running, and which threads are ready but not running. More...

#include <scheduler.h>

List of all members.

Public Methods

 Scheduler ()
 Initialize list of ready threads. More...

 ~Scheduler ()
 De-allocate ready list. More...

void ReadyToRun (Thread *thread)
 Thread can be dispatched. More...

ThreadFindNextToRun ()
 Dequeue first thread on the ready list, if any, and return thread. More...

void Run (Thread *nextThread, bool finishing)
 Cause nextThread to start running. More...

void CheckToBeDestroyed ()
 Check if thread that had been running needs to be deleted. More...

void Print ()
 SelfTest for scheduler is implemented in class Thread. More...


Private Attributes

List<Thread *>* readyList
 queue of threads that are ready to run, but not running. More...

ThreadtoBeDestroyed
 finishing thread to be destroyed by the next thread that runs. More...


Detailed Description

The following class defines the scheduler/dispatcher abstraction -- the data structures and operations needed to keep track of which thread is running, and which threads are ready but not running.

Definition at line 20 of file scheduler.h.


Constructor & Destructor Documentation

Scheduler::Scheduler ( )
 

Initialize list of ready threads.

Scheduler::Scheduler Initialize the list of ready but not running threads. Initially, no ready threads.

Definition at line 32 of file scheduler.cc.

Scheduler::~Scheduler ( )
 

De-allocate ready list.

Scheduler::~Scheduler De-allocate the list of ready threads.

Definition at line 43 of file scheduler.cc.


Member Function Documentation

void Scheduler::CheckToBeDestroyed ( )
 

Check if thread that had been running needs to be deleted.

Scheduler::CheckToBeDestroyed If the old thread gave up the processor because it was finishing, we need to delete its carcass. Note we cannot delete the thread before now (for example, in Thread::Finish()), because up to this point, we were still running on the old thread's stack!

Definition at line 163 of file scheduler.cc.

Thread * Scheduler::FindNextToRun ( )
 

Dequeue first thread on the ready list, if any, and return thread.

Scheduler::FindNextToRun Return the next thread to be scheduled onto the CPU. If there are no ready threads, return NULL. Side effect: Thread is removed from the ready list.

Definition at line 75 of file scheduler.cc.

void Scheduler::Print ( )
 

SelfTest for scheduler is implemented in class Thread.

Scheduler::Print Print the scheduler state -- in other words, the contents of the ready list. For debugging.

Definition at line 177 of file scheduler.cc.

void Scheduler::ReadyToRun ( Thread * thread )
 

Thread can be dispatched.

Scheduler::ReadyToRun Mark a thread as ready, but not running. Put it on the ready list, for later scheduling onto the CPU.

"thread" is the thread to be put on the ready list.

Definition at line 57 of file scheduler.cc.

Referenced by Thread::Fork().

void Scheduler::Run ( Thread * nextThread,
bool finishing )
 

Cause nextThread to start running.

Scheduler::Run Dispatch the CPU to nextThread. Save the state of the old thread, and load the state of the new thread, by calling the machine dependent context switch routine, SWITCH.

Note: we assume the state of the previously running thread has already been changed from running to blocked or ready (depending). Side effect: The global variable kernel->currentThread becomes nextThread.

"nextThread" is the thread to be put into the CPU. "finishing" is set if the current thread is to be deleted once we're no longer running on its stack (when the next thread starts running)

Definition at line 104 of file scheduler.cc.


Member Data Documentation

List< Thread *> * Scheduler::readyList<Thread *> [private]
 

queue of threads that are ready to run, but not running.

Definition at line 38 of file scheduler.h.

Thread * Scheduler::toBeDestroyed [private]
 

finishing thread to be destroyed by the next thread that runs.

Definition at line 40 of file scheduler.h.


The documentation for this class was generated from the following files:
Generated at Wed Jul 4 11:32:24 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001