Dynamic threads related APIs and services.
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] | heapp | heap from which allocate the memory or NULL for the default heap |
[in] | size | size of the working area to be allocated |
[in] | name | thread name |
[in] | prio | the priority level for the new thread |
[in] | pf | the thread function |
[in] | arg | an 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
-
NULL | if 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.
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] | mp | pointer to the memory pool object |
[in] | name | thread name |
[in] | prio | the priority level for the new thread |
[in] | pf | the thread function |
[in] | arg | an 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
-
NULL | if 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.