34 #if defined(OS_HAS_INTERRUPTS_STACK) 68 bool is_started_ =
false;
76 state_t lock_state_ = state::init;
79 #pragma GCC diagnostic push 80 #if defined(__clang__) 81 #pragma clang diagnostic ignored "-Wglobal-constructors" 82 #pragma clang diagnostic ignored "-Wexit-time-destructors" 91 thread::threads_list top_threads_list_;
93 #pragma GCC diagnostic pop 95 #if !defined(OS_USE_RTOS_PORT_SCHEDULER) 97 bool is_preemptive_ =
false;
99 #pragma GCC diagnostic push 100 #pragma GCC diagnostic ignored "-Wpadded" 109 #pragma GCC diagnostic pop 113 #pragma GCC diagnostic push 114 #pragma GCC diagnostic ignored "-Winvalid-offsetof" 115 static_assert(offsetof(tiny_thread_t, errno_) == offsetof(
thread, errno_),
"adjust tiny_thread_t members");
116 #pragma GCC diagnostic pop 118 #pragma GCC diagnostic push 119 #if defined(__clang__) 120 #pragma clang diagnostic ignored "-Wmissing-variable-declarations" 122 tiny_thread_t tiny_thread;
123 #pragma GCC diagnostic pop 125 thread*
volatile current_thread_ =
reinterpret_cast<thread*
>(&tiny_thread);
127 #pragma GCC diagnostic push 128 #if defined(__clang__) 129 #pragma clang diagnostic ignored "-Wglobal-constructors" 130 #pragma clang diagnostic ignored "-Wexit-time-destructors" 132 internal::ready_threads_list ready_threads_list_;
133 #pragma GCC diagnostic pop 136 #pragma GCC diagnostic push 137 #if defined(__clang__) 138 #pragma clang diagnostic ignored "-Wglobal-constructors" 139 #pragma clang diagnostic ignored "-Wexit-time-destructors" 141 internal::terminated_threads_list terminated_threads_list_;
142 #pragma GCC diagnostic pop 159 #if defined(OS_TRACE_RTOS_SCHEDULER) 166 #if defined(OS_USE_RTOS_PORT_SCHEDULER) 198 #if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) 200 scheduler::statistics::context_switches_ = 0;
204 #if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES) 206 scheduler::statistics::cpu_cycles_ = 0;
207 scheduler::statistics::switch_timestamp_ =
hrclock.
now ();
211 #if !defined(OS_USE_RTOS_PORT_SCHEDULER) 228 #if defined(OS_TRACE_RTOS_SCHEDULER) 234 #if defined(OS_USE_RTOS_PORT_SCHEDULER) 245 tmp = is_preemptive_;
246 is_preemptive_ = state;
259 thread::threads_list&
264 return top_threads_list_;
268 return th->children_;
340 node.
thread_->waiting_node_ = &node;
354 node.
thread_->waiting_node_ =
nullptr;
371 node.
thread_->waiting_node_ = &node;
376 timeout_list.
link (timeout_node);
377 timeout_node.
thread.clock_node_ = &timeout_node;
389 timeout_node.
thread.clock_node_ =
nullptr;
394 node.
thread_->waiting_node_ =
nullptr;
401 #if !defined(OS_USE_RTOS_PORT_SCHEDULER) 404 internal_switch_threads (
void)
406 #if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES) 415 - scheduler::statistics::switch_timestamp_);
418 scheduler::statistics::cpu_cycles_ += delta;
421 scheduler::current_thread_->statistics_.cpu_cycles_ += delta;
424 scheduler::statistics::switch_timestamp_ = now;
433 scheduler::current_thread_->internal_relink_running_ ();
436 scheduler::current_thread_ =
437 scheduler::ready_threads_list_.unlink_head ();
447 #if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) 450 scheduler::statistics::context_switches_++;
453 scheduler::current_thread_->statistics_.context_switches_++;
463 #if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) 469 #if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES) 549 #if defined(OS_HAS_INTERRUPTS_STACK) || defined(__DOXYGEN__) 564 return &interrupts_stack;
600 object_named::object_named ()
616 object_named::object_named (
const char* name) :
617 name_ (name != nullptr ? name :
"-")
#define OS_BOOL_RTOS_SCHEDULER_PREEMPTIVE
Default definition for the preemption flag.
#define os_assert_throw(__e, __er)
Assert or throw a system error exception.
port::clock::timestamp_t timestamp_t
Type of variables holding clock time stamps.
void link(timestamp_node &node)
Add a new thread node to the list.
class thread::stack * stack(void)
Get the interrupts stack.
void start(void)
Start the RTOS scheduler.
rtos::thread & thread
Reference to thread who initiated the timeout.
virtual void start(void) override
state_t locked(state_t state)
Lock/unlock the scheduler.
Priority ordered list of threads.
Double linked list node, with thread reference.
int * __errno(void)
Implementation of the library __errno() function.
Interrupts critical section RAII helper.
Double linked list node, with time stamp and thread.
rtos::thread * thread_
Pointer to waiting thread.
clock_highres hrclock
The high resolution clock object instance.
void prepare_suspend(void)
virtual void start(void) override
void start(void)
Start the RTOS scheduler.
clock_rtc rtclock
The real time clock object instance.
POSIX compliant thread, using the default RTOS allocator.
result_t initialize(void)
Initialise the RTOS scheduler.
port::scheduler::state_t state_t
Type of variables holding scheduler state codes.
bool preemptive(void)
Check if the scheduler is in preemptive mode.
Single file µOS++ RTOS definitions.
clock_systick sysclock
The system clock object instance.
int printf(const char *format,...)
Write a formatted string to the trace device.
bool preemptive(void)
Check if the scheduler is in preemptive mode.
Function completed; no errors or events occurred.
Not present in the READY list, waiting for an event.
int * __errno(void)
Per-thread error support.
virtual void start(void) override
Initialise and make the RTC tick.
uint64_t counter_t
Type of variables holding context switches counters.
virtual timestamp_t now(void) override
Tell the current time.
Ordered list of time stamp nodes.
void unlink(void)
Remove the node from the list.
uint32_t result_t
Type of values returned by RTOS functions.
result_t initialize(void)
Initialise the RTOS scheduler.
void link(waiting_thread_node &node)
Add a new thread node to the list.
thread::threads_list & children_threads(thread *th)
Get the children threads.
uint64_t duration_t
Type of variables holding durations in CPU cycles.
#define os_assert_err(__e, __er)
Assert or return an error.
bool in_handler_mode(void)
Check if the CPU is in handler mode.