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. | |
The os::rtos::scheduler namespace groups scheduler types and functions.
| using os::rtos::scheduler::state_t = typedef port::scheduler::state_t |
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 200 of file os-decls.h.
| thread::threads_list & os::rtos::scheduler::children_threads | ( | thread * | th | ) |
| [in] | th | Pointer to thread or nullptr. |
If the input pointer is nullptr, the function returns the list of top level threads.
Definition at line 265 of file os-core.cpp.
Referenced by os_children_threads_iter_begin(), and os_children_threads_iter_end().
| result_t os::rtos::scheduler::initialize | ( | void | ) |
| result::ok | The scheduler was initialised. |
| EPERM | Cannot 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().
Definition at line 164 of file os-core.cpp.
References os::rtos::interrupts::in_handler_mode(), os::rtos::port::scheduler::initialize(), os::rtos::result::ok, os_assert_err, and os::trace::printf().
Referenced by os_sched_initialize(), and osKernelInitialize().
|
inline |
Set the scheduler lock state to locked and return the previous state.
Definition at line 871 of file os-sched.h.
References os::rtos::port::scheduler::lock().
Referenced by os::rtos::scheduler::lockable::lock(), os_sched_lock(), and os::rtos::scheduler::lockable::try_lock().
| [in] | state | The new 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.
Definition at line 901 of file os-sched.h.
References os::rtos::port::scheduler::locked().
|
inline |
| true | The scheduler is locked. |
| false | The scheduler is switching threads (not locked). |
Check if the scheduler is locked on the current thread or is switching threads from the ready list.
Definition at line 858 of file os-sched.h.
References os::rtos::port::scheduler::locked().
Referenced by os::rtos::scheduler::critical_section::~critical_section(), os::rtos::scheduler::uncritical_section::~uncritical_section(), os::rtos::memory_pool::alloc(), os::rtos::thread::join(), os::rtos::mutex::lock(), os_sched_is_locked(), os_sched_set_locked(), os::rtos::message_queue::receive(), os::rtos::message_queue::send(), os::rtos::clock::sleep_for(), os::rtos::clock::sleep_until(), os::rtos::memory_pool::timed_alloc(), os::rtos::mutex::timed_lock(), os::rtos::message_queue::timed_receive(), os::rtos::message_queue::timed_send(), os::rtos::semaphore::timed_wait(), os::rtos::event_flags::timed_wait(), os::rtos::scheduler::lockable::unlock(), os::rtos::event_flags::wait(), os::rtos::semaphore::wait(), and os::rtos::clock::wait_for().
| bool os::rtos::scheduler::preemptive | ( | bool | state | ) |
| [in] | state | The new state of the scheduler preemptive mode. |
Definition at line 231 of file os-core.cpp.
References os::rtos::interrupts::in_handler_mode(), os_assert_throw, os::rtos::port::scheduler::preemptive(), and os::trace::printf().
|
inline |
| true | The scheduler is in preemptive mode. |
| false | The scheduler is not in preemptive mode. |
Check if the scheduler preemption is enabled.
Definition at line 841 of file os-sched.h.
References os::rtos::port::scheduler::preemptive().
Referenced by os_sched_is_preemptive(), and os_sched_set_preemptive().
| void os::rtos::scheduler::start | ( | void | ) |
The scheduler cannot be stopped, it will run forever, but thread switching can be locked/unlocked.
Definition at line 193 of file os-core.cpp.
References os::rtos::hrclock, os::rtos::interrupts::in_handler_mode(), os::rtos::clock_highres::now(), os_assert_throw, OS_BOOL_RTOS_SCHEDULER_PREEMPTIVE, os::trace::printf(), os::rtos::rtclock, os::rtos::port::scheduler::start(), os::rtos::clock_systick::start(), os::rtos::clock_rtc::start(), os::rtos::clock_highres::start(), and os::rtos::sysclock.
Referenced by os_sched_start(), and osKernelStart().
|
inline |
| true | The scheduler was started. |
| false | The scheduler was not started. |
Check if the scheduler was started, i.e. if scheduler::start() was called.
Definition at line 829 of file os-sched.h.
Referenced by os_rtc_handler(), os_sched_is_started(), os_systick_handler(), osKernelRunning(), and os::rtos::this_thread::yield().
|
inline |
Set the scheduler lock state to unlocked and return the previous state.
Definition at line 884 of file os-sched.h.
References os::rtos::port::scheduler::unlock().
Referenced by os_sched_unlock().