ChibiOS/RT  5.1.0
Dynamic Threads
Collaboration diagram for Dynamic Threads:

Detailed Description

Dynamic threads related APIs and services.

Functions

thread_tchThdCreateFromHeap (memory_heap_t *heapp, size_t size, const char *name, tprio_t prio, tfunc_t pf, void *arg)
 Creates a new thread allocating the memory from the heap. More...
 
thread_tchThdCreateFromMemoryPool (memory_pool_t *mp, const char *name, tprio_t prio, tfunc_t pf, void *arg)
 Creates a new thread allocating the memory from the specified memory pool. More...
 

Function Documentation

thread_t * chThdCreateFromHeap ( memory_heap_t heapp,
size_t  size,
const char *  name,
tprio_t  prio,
tfunc_t  pf,
void *  arg 
)

Creates a new thread allocating the memory from the heap.

Precondition
The configuration options CH_CFG_USE_DYNAMIC and CH_CFG_USE_HEAP must be enabled in order to use this function.
Note
A thread can terminate by calling chThdExit() or by simply returning from its main function.
The memory allocated for the thread is not released automatically, it is responsibility of the creator thread to call chThdWait() and then release the allocated memory.
Parameters
[in]heappheap from which allocate the memory or NULL for the default heap
[in]sizesize of the working area to be allocated
[in]namethread name
[in]priothe priority level for the new thread
[in]pfthe thread function
[in]argan argument passed to the thread function. It can be NULL.
Returns
The pointer to the thread_t structure allocated for the thread into the working space area.
Return values
NULLif the memory cannot be allocated.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 82 of file chdynamic.c.

References _thread_memfill(), CH_DBG_STACK_FILL_VALUE, CH_FLAG_MODE_HEAP, chHeapAllocAligned(), chSchWakeupS(), chSysLock(), chSysUnlock(), chThdCreateSuspendedI(), ch_thread::flags, and MSG_OK.

Here is the call graph for this function:

thread_t * chThdCreateFromMemoryPool ( memory_pool_t mp,
const char *  name,
tprio_t  prio,
tfunc_t  pf,
void *  arg 
)

Creates a new thread allocating the memory from the specified memory pool.

Precondition
The configuration options CH_CFG_USE_DYNAMIC and CH_CFG_USE_MEMPOOLS must be enabled in order to use this function.
The pool must be initialized to contain only objects with alignment PORT_WORKING_AREA_ALIGN.
Note
A thread can terminate by calling chThdExit() or by simply returning from its main function.
The memory allocated for the thread is not released automatically, it is responsibility of the creator thread to call chThdWait() and then release the allocated memory.
Parameters
[in]mppointer to the memory pool object
[in]namethread name
[in]priothe priority level for the new thread
[in]pfthe thread function
[in]argan argument passed to the thread function. It can be NULL.
Returns
The pointer to the thread_t structure allocated for the thread into the working space area.
Return values
NULLif the memory pool is empty.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 145 of file chdynamic.c.

References _thread_memfill(), CH_DBG_STACK_FILL_VALUE, CH_FLAG_MODE_MPOOL, chDbgCheck, chPoolAlloc(), chSchWakeupS(), chSysLock(), chSysUnlock(), chThdCreateSuspendedI(), ch_thread::flags, ch_thread::mpool, MSG_OK, and memory_pool_t::object_size.

Here is the call graph for this function: