tac0S
Template Affectional Command Operating System
Public Member Functions | List of all 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>

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...
 
ThreadFindNextToRun ()
 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...
 

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.

Member Function Documentation

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:

Returns
Thread is removed from the ready list.
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.

Parameters
threadis the thread to be put on the ready list.
bool Scheduler::RemoveThreadFromReadyList ( Thread threadToRemove)

Scheduler::RemoveThreadFromReadyList Remove a specific thread from the ready list.

Returns
True if the operation suceed, else false
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.

Parameters
nextThreadis the thread to be put into the CPU.

The documentation for this class was generated from the following files: