Go to index, previous page, next page

scheduler.cc

This module contains the scheduler functions.

This module exports:

void InitScheduler( void ) explained below
void KillThread( Thread * ) explained below
void KillCurrentThread( int inttype ) explained below
void NextThread( int inttype ) explained below
void WakeUpThreadMsg( Thread *current, Threda *dest, int payload, int send ) explained below


Look at the header file: scheduler.e


Module functions:

void InitScheduler( void ) Initialise the idle state_t in the kernel data.
void Idle( void ) This function starts every time there are no ready threads to run.

It checks whether the kernel has reached a deadlock condition (ie. no waiting threads or no thread is waiting for a timing message or IO interrupt) and if so it prints an error message and halts the machine.

Otherwise, it enters a loop which will keep the CPU busy waiting for the next interrupt.

void KillThread( Thread * ) Kills the given thread.

All the children of the thread will be terminated as well.

void KillCurrentThread( int inttype ) It simply kills the running thread and starts the successive one.

inttype is the interrupt during which this function is called.

void NextThread( int inttype ) Starts the first thread in the ready queue. If this is empty, the Idle() routine will be run.

inttype is the interrupt during which this function is called. It's needed to find the right OLD area where to place the new state_t.

void WakeUpThreadMsg( Thread *current, Threda *dest, int payload, int send ) This function wakes up a thread blocked by a MsgRecv().

If send is TRUE, the reply message passed to MsgRecv() will be filled with payload as value and current as sender, otherwise it will assume that these fields have already been set.


Look at the code: scheduler.cc


Go to index, previous page, next page