FreeNOS
Public Types | Public Member Functions | Private Attributes
Scheduler Class Reference

Responsible for deciding which Process may execute on the local Core. More...

#include <Scheduler.h>

Public Types

enum  Result { Success, InvalidArgument }
 Result code. More...
 

Public Member Functions

 Scheduler ()
 Constructor function. More...
 
Size count () const
 Get number of processes on the schedule. More...
 
Result enqueue (Process *proc, bool ignoreState)
 Add a Process to the run schedule. More...
 
Result dequeue (Process *proc, bool ignoreState)
 Remove a Process from the run schedule. More...
 
Processselect ()
 Select the next process to run. More...
 

Private Attributes

Queue< Process *, MAX_PROCSm_queue
 Contains processes ready to run. More...
 

Detailed Description

Responsible for deciding which Process may execute on the local Core.

Definition at line 36 of file Scheduler.h.

Member Enumeration Documentation

◆ Result

Result code.

Enumerator
Success 
InvalidArgument 

Definition at line 43 of file Scheduler.h.

Constructor & Destructor Documentation

◆ Scheduler()

Scheduler::Scheduler ( )

Constructor function.

Definition at line 22 of file Scheduler.cpp.

References DEBUG.

Member Function Documentation

◆ count()

Size Scheduler::count ( ) const

Get number of processes on the schedule.

Returns
Number of processes on the schedule

Definition at line 27 of file Scheduler.cpp.

References Queue< T, N >::count(), and m_queue.

Referenced by dequeue().

◆ dequeue()

Scheduler::Result Scheduler::dequeue ( Process proc,
bool  ignoreState 
)

Remove a Process from the run schedule.

Parameters
procProcess pointer
ignoreStateTrue to not check for the Process state prior to dequeue.
Returns
Result code

Definition at line 44 of file Scheduler.cpp.

References count(), Queue< T, N >::count(), ERROR, FATAL, Process::getID(), Process::getState(), InvalidArgument, m_queue, Queue< T, N >::pop(), Queue< T, N >::push(), Process::Ready, and Success.

Referenced by ProcessManager::dequeueProcess().

◆ enqueue()

Scheduler::Result Scheduler::enqueue ( Process proc,
bool  ignoreState 
)

Add a Process to the run schedule.

Parameters
procProcess pointer
ignoreStateTrue to not check for the Process state prior to dequeue.
Returns
Result code

Definition at line 32 of file Scheduler.cpp.

References ERROR, Process::getID(), Process::getState(), InvalidArgument, m_queue, Queue< T, N >::push(), Process::Ready, and Success.

Referenced by ProcessManager::enqueueProcess().

◆ select()

Process * Scheduler::select ( )

Select the next process to run.

Returns
Process pointer or NULL if no matching process found

Definition at line 69 of file Scheduler.cpp.

References Queue< T, N >::count(), m_queue, NULL, Queue< T, N >::pop(), and Queue< T, N >::push().

Referenced by ProcessManager::schedule().

Field Documentation

◆ m_queue

Queue<Process *, MAX_PROCS> Scheduler::m_queue
private

Contains processes ready to run.

Definition at line 93 of file Scheduler.h.

Referenced by count(), dequeue(), enqueue(), and select().


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