12 #ifndef INCLUDE_DISTORTOS_INTERNAL_SCHEDULER_SCHEDULER_HPP_ 13 #define INCLUDE_DISTORTOS_INTERNAL_SCHEDULER_SCHEDULER_HPP_ 58 int add(ThreadControlBlock& threadControlBlock);
75 int block(ThreadList& container,
ThreadState state,
const UnblockFunctor* unblockFunctor = {});
95 const UnblockFunctor* unblockFunctor = {});
114 const UnblockFunctor* unblockFunctor = {});
358 #endif // INCLUDE_DISTORTOS_INTERNAL_SCHEDULER_SCHEDULER_HPP_ const SoftwareTimerSupervisor & getSoftwareTimerSupervisor() const
Definition: Scheduler.hpp:144
uint64_t contextSwitchCount_
number of context switches
Definition: Scheduler.hpp:348
typename UnsortedIntrusiveList::iterator iterator
iterator of elements on the list
Definition: SortedIntrusiveList.hpp:60
int block(ThreadList &container, ThreadState state, const UnblockFunctor *unblockFunctor={})
Blocks current thread, transferring it to provided container.
Definition: Scheduler.cpp:113
ThreadControlBlock class is a simple description of a Thread.
Definition: ThreadControlBlock.hpp:39
int remove()
Removes current thread from Scheduler's control.
Definition: Scheduler.cpp:204
uint64_t getContextSwitchCount() const
Definition: Scheduler.cpp:175
ThreadControlBlock class header.
void * switchContext(void *stackPointer)
Called by architecture-specific code to do final context switch.
Definition: Scheduler.cpp:241
int blockInternal(ThreadList &container, ThreadList::iterator iterator, ThreadState state, const UnblockFunctor *unblockFunctor)
Blocks thread, transferring it to provided container.
Definition: Scheduler.cpp:324
SoftwareTimerSupervisor & getSoftwareTimerSupervisor()
Definition: Scheduler.hpp:135
ThreadList::iterator currentThreadControlBlock_
iterator to the currently active ThreadControlBlock
Definition: Scheduler.hpp:336
std::chrono::time_point< TickClock > time_point
basic time_point type of clock
Definition: TickClock.hpp:42
int suspend()
Suspends current thread.
Definition: Scheduler.cpp:229
constexpr Scheduler()
Scheduler's constructor.
Definition: Scheduler.hpp:34
SoftwareTimerSupervisor class header.
bool isContextSwitchRequired() const
Tests whether context switch is required or not.
Definition: Scheduler.cpp:340
int add(ThreadControlBlock &threadControlBlock)
Adds new ThreadControlBlock to scheduler.
Definition: Scheduler.cpp:89
uint64_t tickCount_
tick count
Definition: Scheduler.hpp:351
void unblock(ThreadList::iterator iterator, UnblockReason unblockReason=UnblockReason::unblockRequest)
Unblocks provided thread, transferring it from it's current container to "runnable" container.
Definition: Scheduler.cpp:291
Top-level namespace of distortos project.
Definition: buttons.hpp:33
int blockUntil(ThreadList &container, ThreadState state, TickClock::time_point timePoint, const UnblockFunctor *unblockFunctor={})
Blocks current thread with timeout, transferring it to provided container.
Definition: Scheduler.cpp:146
sorted intrusive list of threads (thread control blocks)
Definition: ThreadList.hpp:55
SoftwareTimerSupervisor softwareTimerSupervisor_
internal SoftwareTimerSupervisor object
Definition: Scheduler.hpp:345
Definition: UnblockFunctor.hpp:29
int resume(ThreadList::iterator iterator)
Resumes suspended thread.
Definition: Scheduler.cpp:218
int addInternal(ThreadControlBlock &threadControlBlock)
Adds new ThreadControlBlock to scheduler.
Definition: Scheduler.cpp:311
SoftwareTimerSupervisor class is a supervisor of software timers.
Definition: SoftwareTimerSupervisor.hpp:24
void unblockInternal(ThreadList::iterator iterator, UnblockReason unblockReason)
Unblocks provided thread, transferring it from it's current container to "runnable" container.
Definition: Scheduler.cpp:351
int initialize(ThreadControlBlock &mainThreadControlBlock)
Scheduler's initialization.
Definition: Scheduler.cpp:187
ThreadList runnableList_
list of ThreadControlBlock elements in "runnable" state, sorted by priority in descending order
Definition: Scheduler.hpp:339
UnblockReason
reason of thread unblocking
Definition: UnblockReason.hpp:26
ThreadList suspendedList_
list of ThreadControlBlock elements in "suspended" state, sorted by priority in descending order
Definition: Scheduler.hpp:342
bool tickInterruptHandler()
Handler of "tick" interrupt.
Definition: Scheduler.cpp:260
ThreadState
state of the thread
Definition: ThreadState.hpp:28
void yield()
Yields time slot of the scheduler to next thread.
Definition: Scheduler.cpp:299
explicit request to unblock the thread - normal unblock
void maybeRequestContextSwitch() const
Requests context switch if it is needed.
Definition: Scheduler.cpp:198
uint64_t getTickCount() const
Definition: Scheduler.cpp:181
Scheduler class is a system's scheduler.
Definition: Scheduler.hpp:26
ThreadControlBlock & getCurrentThreadControlBlock() const
Definition: Scheduler.hpp:126