StuBS
Loading...
Searching...
No Matches
Dispatcher Class Reference

The dispatcher dispatches threads and puts the scheduler's decisions into action. More...

#include <dispatcher.h>

Collaboration diagram for Dispatcher:

Public Member Functions

 Dispatcher ()
 constructor
 
Threadactive ()
 Returns the thread running on the CPU core calling this method.
 
Threadactive (int cpu)
 Returns the thread running on the specified CPU core.
 
bool isActive (const Thread *thread, unsigned *getCpuId=nullptr)
 Check if thread is currently active.
 
void go (Thread *first)
 This method stores first as life pointer for this CPU core and triggers the execution of first. Only to be used for the first thread running on a CPU.
 
void dispatch (Thread *next)
 Updates the life pointer to next and issues a thread change from the old to the new life pointer.
 

Private Member Functions

void setActive (Thread *thread)
 set the currently active thread
 

Detailed Description

The dispatcher dispatches threads and puts the scheduler's decisions into action.

The dispatcher manages the life pointer that refers to the currently active thread and performs the actual switching of processes. For single-core systems, a single life pointer is sufficient, as only a single thread can be active at any one time. On multi-core systems, every CPU core needs its own life pointer.

Member Function Documentation

◆ active()

Thread * Dispatcher::active ( int cpu)

Returns the thread running on the specified CPU core.

Parameters
cpuCPU core to check

◆ dispatch()

void Dispatcher::dispatch ( Thread * next)

Updates the life pointer to next and issues a thread change from the old to the new life pointer.

Parameters
nextNext thread to be executed.

◆ go()

void Dispatcher::go ( Thread * first)

This method stores first as life pointer for this CPU core and triggers the execution of first. Only to be used for the first thread running on a CPU.

Parameters
firstFirst thread to be executed on this CPU core.

◆ isActive()

bool Dispatcher::isActive ( const Thread * thread,
unsigned * getCpuId = nullptr )

Check if thread is currently active.

Parameters
threadPointer to the thread in question
getCpuIdIf not null, the core that the thread is running on, if applicable
Returns
true if currently running, false otherwise

◆ setActive()

void Dispatcher::setActive ( Thread * thread)
inlineprivate

set the currently active thread

Parameters
threadactive Thread

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