|
modm API documentation
|
#include <modm/processing/rtos/thread.hpp>
Classes | |
| class | Lock |
| When created suspends all real time kernel activity while keeping interrupts (including the kernel tick) enabled More... | |
Public Member Functions | |
| Thread (uint32_t priority=0, uint16_t stackDepth=minimalStackSize, const char *name=nullptr) | |
| Create a Thread. More... | |
| virtual | ~Thread () |
| Delete the thread. | |
| uint32_t | getPriority () const |
| Obtain the priority of the thread. | |
| void | setPriority (uint32_t priority) |
| Set the priority of the thread. More... | |
Protected Member Functions | |
| virtual void | run () = 0 |
| Worker function. More... | |
Static Protected Member Functions | |
| static void | sleep (TickType_t ticks) |
| Delay for the number of ticks. More... | |
| static void | yield () |
| Force a context switch. More... | |
suspend() and resume() are dangerous and are therefore not available.
Example: thread 1 1) lock mutex M 2) do something 3) unlock mutex
thread 2 1) suspend thread 1 2) lock mutex 3) unlock mutex M 4) resume thread 1
If 2.1 happens during 1.2 the first flow for ever brakes, and the second - is for ever tired of waiting.
Use modm::rtos::Semaphore if you need to suspend the execution of a thread.
Sideeffects: Thread constructor disables the SysTickTimer until the Scheduler is called.
| modm::rtos::Thread::Thread | ( | uint32_t | priority = 0, |
| uint16_t | stackDepth = minimalStackSize, |
||
| const char * | name = nullptr |
||
| ) |
Create a Thread.
| priority | Priority (default is 0) |
| stackDepth | Stack size for the thread in bytes |
| name | Name of the thread (only used for debugging, can be left empty) |
|
protectedpure virtual |
Worker function.
Must be implemented to never return (i.e. continuous loop)
| void modm::rtos::Thread::setPriority | ( | uint32_t | priority | ) |
Set the priority of the thread.
Might cause a context switch if the priority is set to lower value than the highest priority of a thread ready to run.
|
inlinestaticprotected |
Delay for the number of ticks.
Use the MILLISECONDS macro to convert ticks to milliseconds:
| ticks | Number of scheduler ticks to delay for |
|
inlinestaticprotected |
Force a context switch.
Gives control to other threads ready to run.