12#ifndef CMSIS_PLUS_RTOS_OS_SCHED_H_
13#define CMSIS_PLUS_RTOS_OS_SCHED_H_
17#if defined(__cplusplus)
21#if defined(OS_USE_OS_APP_CONFIG_H)
22#include <cmsis-plus/os-app-config.h>
30#pragma GCC diagnostic push
32#pragma clang diagnostic ignored "-Wc++98-compat"
33#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
52 extern bool is_started_;
54#if !defined(OS_USE_RTOS_PORT_SCHEDULER)
55 extern bool is_preemptive_;
56 extern thread*
volatile current_thread_;
57 extern internal::ready_threads_list ready_threads_list_;
60 extern internal::terminated_threads_list terminated_threads_list_;
157 internal_switch_threads (
void);
428#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
450#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
843#if !defined(OS_USE_RTOS_PORT_SCHEDULER)
844 return is_preemptive_;
914#if defined(OS_TRACE_RTOS_SCHEDULER)
928#if defined(OS_TRACE_RTOS_SCHEDULER)
942#if defined(OS_TRACE_RTOS_SCHEDULER)
956#if defined(OS_TRACE_RTOS_SCHEDULER)
1008 namespace statistics
1010#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
1029 return context_switches_;
1034#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
1059#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) \
1060 || defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
1077#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
1078 context_switches_ = 0;
1081#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
1095 namespace interrupts
1100 inline bool __attribute__ ((always_inline))
1109 inline __attribute__ ((always_inline))
1118 inline __attribute__ ((always_inline))
1127 inline state_t __attribute__ ((always_inline))
1136 inline void __attribute__ ((always_inline))
1147 inline __attribute__ ((always_inline))
1156 inline __attribute__ ((always_inline))
1165 inline state_t __attribute__ ((always_inline))
1174 inline void __attribute__ ((always_inline))
1199 inline void __attribute__ ((always_inline))
1212 inline bool __attribute__ ((always_inline))
1222 inline void __attribute__ ((always_inline))
1234#pragma GCC diagnostic pop
Interrupts critical section RAII helper.
critical_section()
Enter an interrupts critical section.
static void exit(state_t state)
Exit the interrupts critical section.
~critical_section()
Exit the interrupts critical section.
static state_t enter(void)
Enter an interrupts critical section.
Interrupts standard locker.
void lock(void)
Lock the interrupts.
~lockable()
Destruct the interrupts lock.
bool try_lock(void)
Try to lock the interrupts.
void unlock(void)
Unlock the interrupts.
constexpr lockable()
Construct an interrupts lock.
Interrupts critical section RAII helper.
~uncritical_section()
Exit the interrupts uncritical section.
static state_t enter(void)
Enter interrupts uncritical section.
static void exit(state_t state)
Exit interrupts uncritical section.
uncritical_section()
Enter an interrupts uncritical section.
static rtos::interrupts::state_t enter(void)
static void exit(rtos::interrupts::state_t state)
static void exit(rtos::interrupts::state_t state)
static rtos::interrupts::state_t enter(void)
Scheduler critical section RAII helper.
critical_section()
Enter a critical section.
~critical_section()
Exit a critical section.
Scheduler standard locker.
void unlock(void)
Unlock the scheduler.
constexpr lockable()
Construct a lockable object instance.
void lock(void)
Lock the scheduler.
~lockable()
Destruct the lockable object instance.
bool try_lock(void)
Try to lock the scheduler.
Scheduler uncritical section RAII helper.
uncritical_section()
Enter a critical section.
~uncritical_section()
Exit a critical section.
int printf(const char *format,...)
Write a formatted string to the trace device.
port::clock::timestamp_t timestamp_t
Type of variables holding clock time stamps.
port::interrupts::state_t state_t
Type of variables holding interrupts status codes.
bool in_handler_mode(void)
Check if the CPU is in handler mode.
bool in_handler_mode(void)
port::scheduler::state_t unlock(void)
port::scheduler::state_t lock(void)
rtos::statistics::duration_t cpu_cycles(void)
Get the total duration of all threads.
rtos::statistics::counter_t context_switches(void)
Get the total number of context switches.
port::scheduler::state_t state_t
Type of variables holding scheduler state codes.
state_t unlock(void)
Unlock the scheduler.
void start(void)
Start the RTOS scheduler.
bool started(void)
Check if the scheduler was started.
state_t lock(void)
Lock the scheduler.
result_t initialize(void)
Initialise the RTOS scheduler.
bool preemptive(void)
Check if the scheduler is in preemptive mode.
bool locked(void)
Check if the scheduler is locked.
uint64_t duration_t
Type of variables holding durations in CPU cycles.
uint64_t counter_t
Type of variables holding context switches counters.
uint32_t result_t
Type of values returned by RTOS functions.