28#ifndef CMSIS_PLUS_RTOS_OS_SCHED_H_
29#define CMSIS_PLUS_RTOS_OS_SCHED_H_
33#if defined(__cplusplus)
42#pragma GCC diagnostic push
45#pragma clang diagnostic ignored "-Wc++98-compat"
46#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
65 extern bool is_started_;
67#if !defined(OS_USE_RTOS_PORT_SCHEDULER)
68 extern bool is_preemptive_;
69 extern thread*
volatile current_thread_;
70 extern internal::ready_threads_list ready_threads_list_;
73 extern internal::terminated_threads_list terminated_threads_list_;
170 internal_switch_threads (
void);
350 operator= (
const lockable&) =
delete;
439#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
460#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
483#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) \
484 || defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
755 operator= (
const lockable&) =
delete;
867#if !defined(OS_USE_RTOS_PORT_SCHEDULER)
868 return is_preemptive_;
940#if defined(OS_TRACE_RTOS_SCHEDULER)
955#if defined(OS_TRACE_RTOS_SCHEDULER)
971#if defined(OS_TRACE_RTOS_SCHEDULER)
986#if defined(OS_TRACE_RTOS_SCHEDULER)
997 state_ (port::scheduler::state::init)
1043 namespace statistics
1045#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
1064 return context_switches_;
1069#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
1094#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) \
1095 || defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
1111#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
1112 context_switches_ = 0;
1115#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
1129 namespace interrupts
1135 __attribute__((always_inline))
1145 __attribute__((always_inline))
1156 __attribute__((always_inline))
1166 __attribute__((always_inline))
1176 __attribute__((always_inline))
1188 __attribute__((always_inline))
1199 __attribute__((always_inline))
1209 __attribute__((always_inline))
1219 __attribute__((always_inline))
1232 state_ (port::interrupts::state::init)
1241 __attribute__((always_inline))
1251 __attribute__((always_inline))
1265 __attribute__((always_inline))
1276 __attribute__((always_inline))
1288#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 statu 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.