ChibiOS 21.11.5
chdynamic.h
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006-2026 Giovanni Di Sirio.
3
4 This file is part of ChibiOS.
5
6 ChibiOS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation version 3 of the License.
9
10 ChibiOS is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/**
20 * @file rt/include/chdynamic.h
21 * @brief Dynamic threads macros and structures.
22 *
23 * @addtogroup dynamic_threads
24 * @{
25 */
26
27#ifndef CHDYNAMIC_H
28#define CHDYNAMIC_H
29
30#if (CH_CFG_USE_DYNAMIC == TRUE) || defined(__DOXYGEN__)
31
32/*===========================================================================*/
33/* Module constants. */
34/*===========================================================================*/
35
36/*===========================================================================*/
37/* Module pre-compile time settings. */
38/*===========================================================================*/
39
40/*===========================================================================*/
41/* Derived constants and error checks. */
42/*===========================================================================*/
43
44/*
45 * Module dependencies check.
46 */
47#if CH_CFG_USE_WAITEXIT == FALSE
48#error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_WAITEXIT"
49#endif
50
51#if CH_CFG_USE_REGISTRY == FALSE
52#error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_REGISTRY"
53#endif
54
55#if (CH_CFG_USE_HEAP == FALSE) && (CH_CFG_USE_MEMPOOLS == FALSE)
56#error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_HEAP and/or CH_CFG_USE_MEMPOOLS"
57#endif
58
59/*===========================================================================*/
60/* Module data structures and types. */
61/*===========================================================================*/
62
63/*===========================================================================*/
64/* Module macros. */
65/*===========================================================================*/
66
67/*===========================================================================*/
68/* External declarations. */
69/*===========================================================================*/
70
71/*
72 * Dynamic threads APIs.
73 */
74#ifdef __cplusplus
75extern "C" {
76#endif
77#if CH_CFG_USE_HEAP == TRUE
78 thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
79 const char *name, tprio_t prio,
80 tfunc_t pf, void *arg);
81#endif
82#if CH_CFG_USE_MEMPOOLS == TRUE
84 tprio_t prio, tfunc_t pf, void *arg);
85#endif
86#ifdef __cplusplus
87}
88#endif
89
90/*===========================================================================*/
91/* Module inline functions. */
92/*===========================================================================*/
93
94#endif /* CH_CFG_USE_DYNAMIC == TRUE */
95
96#endif /* CHDYNAMIC_H */
97
98/** @} */
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.
Definition chdynamic.c:81
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.
Definition chdynamic.c:136
uint32_t tprio_t
Definition chearly.h:86
struct ch_thread thread_t
Type of a thread structure.
Definition chearly.h:132
struct memory_heap memory_heap_t
Type of a memory heap.
Definition chmemheaps.h:71
void(* tfunc_t)(void *p)
Thread function.
Definition chthreads.h:51
Memory pool descriptor.
Definition chmempools.h:63