20#ifndef ZEPHYR_INCLUDE_KERNEL_STRUCTS_H_
21#define ZEPHYR_INCLUDE_KERNEL_STRUCTS_H_
23#if !defined(_ASMLANGUAGE)
33#if defined(CONFIG_TIMEOUT_BACKEND_MINHEAP)
38#define K_NUM_THREAD_PRIO (CONFIG_NUM_PREEMPT_PRIORITIES + CONFIG_NUM_COOP_PRIORITIES + 1)
39#define PRIQ_BITMAP_SIZE (DIV_ROUND_UP(K_NUM_THREAD_PRIO, BITS_PER_LONG))
55#define _THREAD_DUMMY (BIT(0))
58#define _THREAD_PENDING (BIT(1))
61#define _THREAD_SLEEPING (BIT(2))
64#define _THREAD_DEAD (BIT(3))
67#define _THREAD_SUSPENDED (BIT(4))
70#define _THREAD_ABORTING (BIT(5))
73#define _THREAD_SUSPENDING (BIT(6))
76#define _THREAD_QUEUED (BIT(7))
80#ifdef CONFIG_STACK_SENTINEL
82#define STACK_SENTINEL 0xF0F0F0F0
86#define _NON_PREEMPT_THRESHOLD 0x0080U
89#define _PREEMPT_THRESHOLD (_NON_PREEMPT_THRESHOLD - 1U)
91#if !defined(_ASMLANGUAGE)
126 unsigned int cached_queue_index;
136#if defined(CONFIG_SCHED_SIMPLE)
138#elif defined(CONFIG_SCHED_SCALABLE)
139 struct _priq_rb runq;
140#elif defined(CONFIG_SCHED_MULTIQ)
141 struct _priq_mq runq;
145typedef struct _ready_q _ready_q_t;
148#ifndef CONFIG_KERNEL_COHERENCE
149#define Z_DCACHE_ALIGN_SMP_CPU Z_DCACHE_ALIGN_SMP
151#define Z_DCACHE_ALIGN_SMP_CPU
167#ifdef CONFIG_SCHED_CPU_MASK_PIN_ONLY
168 struct _ready_q ready_q;
171#if (CONFIG_NUM_METAIRQ_PRIORITIES > 0)
178#if defined(CONFIG_FPU_SHARING)
187#ifdef CONFIG_SCHED_THREAD_USAGE
196#ifdef CONFIG_SCHED_THREAD_USAGE_ALL
201#ifdef CONFIG_OBJ_CORE_SYSTEM
205#ifdef CONFIG_SCHED_IPI_SUPPORTED
210 struct _cpu_arch arch;
211} Z_DCACHE_ALIGN_SMP_CPU;
213typedef struct _cpu _cpu_t;
216 struct _cpu cpus[CONFIG_MP_MAX_NUM_CPUS];
226#ifndef CONFIG_SCHED_CPU_MASK_PIN_ONLY
227 struct _ready_q ready_q;
230#if defined(CONFIG_THREAD_MONITOR)
233#ifdef CONFIG_SCHED_THREAD_USAGE_ALL
237#ifdef CONFIG_OBJ_CORE_SYSTEM
241#if defined(CONFIG_SMP) && defined(CONFIG_SCHED_IPI_SUPPORTED)
246#if defined(CONFIG_IPI_OPTIMIZE_IDLE)
253 struct k_thread *sched_ipi_target[CONFIG_MP_MAX_NUM_CPUS];
257typedef struct z_kernel _kernel_t;
259extern struct z_kernel _kernel;
268bool z_smp_cpu_mobile(
void);
269#define _current_cpu ({ __ASSERT_NO_MSG(!z_smp_cpu_mobile()); \
272#define _current_cpu (&_kernel.cpus[0])
285#define _raw_current (_current_cpu->current)
288__attribute_const__
struct k_thread *z_smp_current_get(
void);
289#define _current z_smp_current_get()
291#define _current _raw_current
294#define CPU_ID ((CONFIG_MP_MAX_NUM_CPUS == 1) ? 0 : _current_cpu->id)
305#define z_current_thread_set(thread) ({ _raw_current = (thread); })
307#ifdef CONFIG_ARCH_HAS_CUSTOM_CURRENT_IMPL
309#define _current arch_current_thread()
310#undef z_current_thread_set
311#define z_current_thread_set(thread) \
312 arch_current_thread_set(({ _raw_current = (thread); }))
316#ifdef CONFIG_WAITQ_SCALABLE
319 struct _priq_rb waitq;
323bool z_priq_rb_lessthan(
struct rbnode *a,
struct rbnode *b);
325#define Z_WAIT_Q_INIT(wait_q) { { { .lessthan_fn = z_priq_rb_lessthan } } }
333#define Z_WAIT_Q_INIT(wait_q) { SYS_DLIST_STATIC_INIT(&(wait_q)->waitq) }
339typedef void (*_timeout_func_t)(
struct _timeout *t);
348#if defined(CONFIG_TIMEOUT_BACKEND_MINHEAP)
355 struct min_heap_handle heap_handle;
356#elif defined(CONFIG_TIMEOUT_BACKEND_SKIPLIST)
364 struct _timeout *forward[CONFIG_TIMEOUT_SKIPLIST_MAX_LEVEL];
373#if defined(CONFIG_TIMEOUT_BACKEND_WHEEL)
376#ifdef CONFIG_TIMEOUT_64BIT
Header file for the doubly-linked list API.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:34
struct _dnode sys_dnode_t
Doubly-linked list node structure.
Definition dlist.h:59
struct _dnode sys_dlist_t
Doubly-linked list structure.
Definition dlist.h:55
#define PRIQ_BITMAP_SIZE
Definition kernel_structs.h:39
void(* k_thread_timeslice_fn_t)(struct k_thread *thread, void *data)
Definition kernel_structs.h:386
#define K_NUM_THREAD_PRIO
Definition kernel_structs.h:38
Header-file for the reference (handle-based) min-heap data structure.
flags
Definition parser.h:86
Header file for the balanced red/black tree API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__INT64_TYPE__ int64_t
Definition stdint.h:75
Structure used to track internal statistics about both thread and CPU usage.
Definition stats.h:18
Object core structure.
Definition obj_core.h:160
Thread Structure.
Definition thread.h:258
Balanced red/black tree node structure.
Definition rb.h:61
Balanced red/black tree structure.
Definition rb.h:94
Header file for the Atomic operations API.