µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::rtos::scheduler Namespace Reference

Scheduler namespace. More...

Namespaces

namespace  statistics
 Scheduler statistics.
 

Classes

class  critical_section
 Scheduler critical section RAII helper. More...
 
class  lockable
 Scheduler standard locker. More...
 
class  uncritical_section
 Scheduler uncritical section RAII helper. More...
 

Typedefs

using state_t = port::scheduler::state_t
 Type of variables holding scheduler state codes.
 

Functions

thread::threads_list & children_threads (thread *th)
 Get the children threads.
 
result_t initialize (void)
 Initialise the RTOS scheduler.
 
state_t lock (void)
 Lock the scheduler.
 
state_t locked (state_t state)
 Lock/unlock the scheduler.
 
bool locked (void)
 Check if the scheduler is locked.
 
bool preemptive (bool state)
 Set the scheduler preemptive mode.
 
bool preemptive (void)
 Check if the scheduler is in preemptive mode.
 
void start (void)
 Start the RTOS scheduler.
 
bool started (void)
 Check if the scheduler was started.
 
state_t unlock (void)
 Unlock the scheduler.
 

Detailed Description

Scheduler namespace.

The os::rtos::scheduler namespace groups scheduler types and functions.

Typedef Documentation

◆ state_t

using os::rtos::scheduler::state_t = typedef port::scheduler::state_t

Type of variables holding scheduler state codes.

Usually a boolean telling if the scheduler is locked or not, but for recursive locks it might also be a numeric counter.

Definition at line 202 of file os-decls.h.

Function Documentation

◆ children_threads()

thread::threads_list & os::rtos::scheduler::children_threads ( thread th)

Get the children threads.

Parameters
[in]thPointer to thread or nullptr.
Returns
Reference to children list.

If the input pointer is nullptr, the function returns the list of top level threads.

Definition at line 261 of file os-core.cpp.

◆ initialize()

result_t os::rtos::scheduler::initialize ( void  )

Initialise the RTOS scheduler.

Parameters
None.
Return values
result::okThe scheduler was initialised.
EPERMCannot be invoked from an Interrupt Service Routines.

Initialise all RTOS internal objects and be ready to run.

Must be called only once, usually in main().

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 160 of file os-core.cpp.

◆ lock()

state_t os::rtos::scheduler::lock ( void  )
inline

Lock the scheduler.

Parameters
None.
Returns
The previous state of the scheduler lock.

Set the scheduler lock state to locked and return the previous state.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 869 of file os-sched.h.

◆ locked() [1/2]

state_t os::rtos::scheduler::locked ( state_t  state)
inline

Lock/unlock the scheduler.

Parameters
[in]stateThe new state of the scheduler lock.
Returns
The previous state of the scheduler lock.

Set the scheduler lock state based on the parameter and return the previous state.

This allows to implement scheduler critical sections, where the scheduler is disabled and context switches are not performed.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 899 of file os-sched.h.

◆ locked() [2/2]

bool os::rtos::scheduler::locked ( void  )
inline

Check if the scheduler is locked.

Parameters
None.
Return values
trueThe scheduler is locked.
falseThe scheduler is switching threads (not locked).

Check if the scheduler is locked on the current thread or is switching threads from the ready list.

Note
Can be invoked from Interrupt Service Routines.

Definition at line 856 of file os-sched.h.

◆ preemptive() [1/2]

bool os::rtos::scheduler::preemptive ( bool  state)

Set the scheduler preemptive mode.

Parameters
[in]stateThe new state of the scheduler preemptive mode.
Returns
The previous state of the preemptive mode.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 227 of file os-core.cpp.

◆ preemptive() [2/2]

bool os::rtos::scheduler::preemptive ( void  )
inline

Check if the scheduler is in preemptive mode.

Parameters
None
Return values
trueThe scheduler is in preemptive mode.
falseThe scheduler is not in preemptive mode.

Check if the scheduler preemption is enabled.

Note
Can be invoked from Interrupt Service Routines.

Definition at line 839 of file os-sched.h.

◆ start()

void os::rtos::scheduler::start ( void  )

Start the RTOS scheduler.

Parameters
None.
Returns
Nothing.

The scheduler cannot be stopped, it will run forever, but thread switching can be locked/unlocked.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 189 of file os-core.cpp.

◆ started()

bool os::rtos::scheduler::started ( void  )
inline

Check if the scheduler was started.

Parameters
None.
Return values
trueThe scheduler was started.
falseThe scheduler was not started.

Check if the scheduler was started, i.e. if scheduler::start() was called.

Note
Can be invoked from Interrupt Service Routines.

Definition at line 827 of file os-sched.h.

◆ unlock()

state_t os::rtos::scheduler::unlock ( void  )
inline

Unlock the scheduler.

Parameters
None.
Returns
The previous state of the scheduler lock.

Set the scheduler lock state to unlocked and return the previous state.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 882 of file os-sched.h.