tac0S
Template Affectional Command Operating System
|
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>
Public Member Functions | |
Scheduler () | |
Scheduler::Scheduler Initialize the list of ready but not running threads to empty. | |
~Scheduler () | |
Scheduler::~Scheduler De-allocate the list of ready threads. | |
void | ReadyToRun (Thread *thread) |
Scheduler::ReadyToRun Mark a thread as ready, but not running. Put it on the ready list, for later scheduling onto the CPU. More... | |
Thread * | FindNextToRun () |
Scheduler::FindNextToRun Return the next thread to be scheduled onto the CPU. If there are no ready threads, return NULL. Side effect: More... | |
void | Run (Thread *nextThread) |
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. More... | |
void | Print () |
Scheduler::Print Print the scheduler state – in other words, the contents of the ready list. For debugging. | |
bool | RemoveThreadFromReadyList (Thread *threadToRemove) |
Scheduler::RemoveThreadFromReadyList Remove a specific thread from the ready list. More... | |
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.
Thread * Scheduler::FindNextToRun | ( | ) |
Scheduler::FindNextToRun Return the next thread to be scheduled onto the CPU. If there are no ready threads, return NULL. Side effect:
void Scheduler::ReadyToRun | ( | Thread * | thread | ) |
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. |
bool Scheduler::RemoveThreadFromReadyList | ( | Thread * | threadToRemove | ) |
Scheduler::RemoveThreadFromReadyList Remove a specific thread from the ready list.
void Scheduler::Run | ( | Thread * | nextThread | ) |
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 currentThread becomes nextThread.
nextThread | is the thread to be put into the CPU. |