ChibiOS/RT  5.1.0
chthreads.h File Reference

Threads module macros and structures. More...

Go to the source code of this file.

Data Structures

struct  thread_descriptor_t
 Type of a thread descriptor. More...
 

Macros

Threads queues
#define _THREADS_QUEUE_DATA(name)   {(thread_t *)&name, (thread_t *)&name}
 Data part of a static threads queue object initializer. More...
 
#define _THREADS_QUEUE_DECL(name)   threads_queue_t name = _THREADS_QUEUE_DATA(name)
 Static threads queue object initializer. More...
 
Working Areas
#define THD_WORKING_AREA_SIZE(n)   MEM_ALIGN_NEXT(sizeof(thread_t) + PORT_WA_SIZE(n), PORT_STACK_ALIGN)
 Calculates the total Working Area size. More...
 
#define THD_WORKING_AREA(s, n)   PORT_WORKING_AREA(s, n)
 Static working area allocation. More...
 
#define THD_WORKING_AREA_BASE(s)   ((stkalign_t *)(s))
 Base of a working area casted to the correct type. More...
 
#define THD_WORKING_AREA_END(s)
 End of a working area casted to the correct type. More...
 
Threads abstraction macros
#define THD_FUNCTION(tname, arg)   PORT_THD_FUNCTION(tname, arg)
 Thread declaration macro. More...
 
Macro Functions
#define chThdSleepSeconds(sec)   chThdSleep(TIME_S2I(sec))
 Delays the invoking thread for the specified number of seconds. More...
 
#define chThdSleepMilliseconds(msec)   chThdSleep(TIME_MS2I(msec))
 Delays the invoking thread for the specified number of milliseconds. More...
 
#define chThdSleepMicroseconds(usec)   chThdSleep(TIME_US2I(usec))
 Delays the invoking thread for the specified number of microseconds. More...
 

Typedefs

typedef void(* tfunc_t) (void *p)
 Thread function. More...
 

Functions

thread_t_thread_init (thread_t *tp, const char *name, tprio_t prio)
 Initializes a thread structure. More...
 
void _thread_memfill (uint8_t *startp, uint8_t *endp, uint8_t v)
 Memory fill utility. More...
 
thread_tchThdCreateSuspendedI (const thread_descriptor_t *tdp)
 Creates a new thread into a static memory area. More...
 
thread_tchThdCreateSuspended (const thread_descriptor_t *tdp)
 Creates a new thread into a static memory area. More...
 
thread_tchThdCreateI (const thread_descriptor_t *tdp)
 Creates a new thread into a static memory area. More...
 
thread_tchThdCreate (const thread_descriptor_t *tdp)
 Creates a new thread into a static memory area. More...
 
thread_tchThdCreateStatic (void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg)
 Creates a new thread into a static memory area. More...
 
thread_tchThdStart (thread_t *tp)
 Resumes a thread created with chThdCreateI(). More...
 
thread_tchThdAddRef (thread_t *tp)
 Adds a reference to a thread object. More...
 
void chThdRelease (thread_t *tp)
 Releases a reference to a thread object. More...
 
void chThdExit (msg_t msg)
 Terminates the current thread. More...
 
void chThdExitS (msg_t msg)
 Terminates the current thread. More...
 
msg_t chThdWait (thread_t *tp)
 Blocks the execution of the invoking thread until the specified thread terminates then the exit code is returned. More...
 
tprio_t chThdSetPriority (tprio_t newprio)
 Changes the running thread priority level then reschedules if necessary. More...
 
void chThdTerminate (thread_t *tp)
 Requests a thread termination. More...
 
msg_t chThdSuspendS (thread_reference_t *trp)
 Sends the current thread sleeping and sets a reference variable. More...
 
msg_t chThdSuspendTimeoutS (thread_reference_t *trp, sysinterval_t timeout)
 Sends the current thread sleeping and sets a reference variable. More...
 
void chThdResumeI (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object. More...
 
void chThdResumeS (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object. More...
 
void chThdResume (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object. More...
 
msg_t chThdEnqueueTimeoutS (threads_queue_t *tqp, sysinterval_t timeout)
 Enqueues the caller thread on a threads queue object. More...
 
void chThdDequeueNextI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up one thread from the threads queue object, if any. More...
 
void chThdDequeueAllI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up all threads from the threads queue object. More...
 
void chThdSleep (sysinterval_t time)
 Suspends the invoking thread for the specified time. More...
 
void chThdSleepUntil (systime_t time)
 Suspends the invoking thread until the system time arrives to the specified value. More...
 
systime_t chThdSleepUntilWindowed (systime_t prev, systime_t next)
 Suspends the invoking thread until the system time arrives to the specified value. More...
 
void chThdYield (void)
 Yields the time slot. More...
 
static thread_tchThdGetSelfX (void)
 Returns a pointer to the current thread_t. More...
 
static tprio_t chThdGetPriorityX (void)
 Returns the current thread priority. More...
 
static systime_t chThdGetTicksX (thread_t *tp)
 Returns the number of ticks consumed by the specified thread. More...
 
static stkalign_t * chThdGetWorkingAreaX (thread_t *tp)
 Returns the working area base of the specified thread. More...
 
static bool chThdTerminatedX (thread_t *tp)
 Verifies if the specified thread is in the CH_STATE_FINAL state. More...
 
static bool chThdShouldTerminateX (void)
 Verifies if the current thread has a termination request pending. More...
 
static thread_tchThdStartI (thread_t *tp)
 Resumes a thread created with chThdCreateI(). More...
 
static void chThdSleepS (sysinterval_t ticks)
 Suspends the invoking thread for the specified number of ticks. More...
 
static void chThdQueueObjectInit (threads_queue_t *tqp)
 Initializes a threads queue object. More...
 
static bool chThdQueueIsEmptyI (threads_queue_t *tqp)
 Evaluates to true if the specified queue is empty. More...
 
static void chThdDoDequeueNextI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up one thread from the threads queue object. More...
 

Detailed Description

Threads module macros and structures.

Definition in file chthreads.h.