modm API documentation
modm::rtos::Thread Class Referenceabstract

Thread. More...

#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...
 

Detailed Description

Thread.

FreeRTOS suspend()/resume()

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.

Constructor & Destructor Documentation

modm::rtos::Thread::Thread ( uint32_t  priority = 0,
uint16_t  stackDepth = minimalStackSize,
const char *  name = nullptr 
)

Create a Thread.

Parameters
priorityPriority (default is 0)
stackDepthStack size for the thread in bytes
nameName of the thread (only used for debugging, can be left empty)
Warning
Threads may not be created while the scheduler is running! Create them be before calling Scheduler::schedule() or stop the scheduler and restart it afterwards.

Member Function Documentation

virtual void modm::rtos::Thread::run ( )
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.

static void modm::rtos::Thread::sleep ( TickType_t  ticks)
inlinestaticprotected

Delay for the number of ticks.

Use the MILLISECONDS macro to convert ticks to milliseconds:

Parameters
ticksNumber of scheduler ticks to delay for
See also
MILLISECONDS
static void modm::rtos::Thread::yield ( )
inlinestaticprotected

Force a context switch.

Gives control to other threads ready to run.


The documentation for this class was generated from the following files: