123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- #ifndef ZEPHYR_INCLUDE_KERNEL_THREAD_H_
- #define ZEPHYR_INCLUDE_KERNEL_THREAD_H_
- #ifdef CONFIG_DEMAND_PAGING_THREAD_STATS
- #include <sys/mem_manage.h>
- #endif
- #ifdef CONFIG_THREAD_MONITOR
- struct __thread_entry {
- k_thread_entry_t pEntry;
- void *parameter1;
- void *parameter2;
- void *parameter3;
- };
- #endif
- struct _thread_base {
-
- union {
- sys_dnode_t qnode_dlist;
- struct rbnode qnode_rb;
- };
-
- _wait_q_t *pended_on;
-
- uint8_t user_options;
-
- uint8_t thread_state;
-
- union {
- struct {
- #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
- uint8_t sched_locked;
- int8_t prio;
- #else
- int8_t prio;
- uint8_t sched_locked;
- #endif
- };
- uint16_t preempt;
- };
- #ifdef CONFIG_SCHED_DEADLINE
- int prio_deadline;
- #endif
- uint32_t order_key;
- #ifdef CONFIG_SMP
-
- uint8_t is_idle;
-
- uint8_t cpu;
-
- uint8_t global_lock_count;
- #endif
- #ifdef CONFIG_SCHED_CPU_MASK
-
- uint8_t cpu_mask;
- #endif
-
- void *swap_data;
- #ifdef CONFIG_SYS_CLOCK_EXISTS
-
- struct _timeout timeout;
- #endif
- };
- typedef struct _thread_base _thread_base_t;
- #if defined(CONFIG_THREAD_STACK_INFO)
- struct _thread_stack_info {
-
- uintptr_t start;
-
- size_t size;
-
- size_t delta;
- };
- typedef struct _thread_stack_info _thread_stack_info_t;
- #endif
- #if defined(CONFIG_USERSPACE)
- struct _mem_domain_info {
-
- sys_dnode_t mem_domain_q_node;
-
- struct k_mem_domain *mem_domain;
- };
- #endif
- #ifdef CONFIG_THREAD_USERSPACE_LOCAL_DATA
- struct _thread_userspace_local_data {
- #if defined(CONFIG_ERRNO) && !defined(CONFIG_ERRNO_IN_TLS)
- int errno_var;
- #endif
- };
- #endif
- #ifdef CONFIG_THREAD_RUNTIME_STATS
- struct k_thread_runtime_stats {
-
- #ifdef CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS
- timing_t execution_cycles;
- #else
- uint64_t execution_cycles;
- #endif
- };
- typedef struct k_thread_runtime_stats k_thread_runtime_stats_t;
- struct _thread_runtime_stats {
-
- #ifdef CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS
- timing_t last_switched_in;
- #else
- uint32_t last_switched_in;
- #endif
- k_thread_runtime_stats_t stats;
- };
- #endif
- struct z_poller {
- bool is_polling;
- uint8_t mode;
- };
- struct k_thread {
- struct _thread_base base;
-
- struct _callee_saved callee_saved;
-
- void *init_data;
-
- _wait_q_t join_queue;
- #if defined(CONFIG_POLL)
- struct z_poller poller;
- #endif
- #if defined(CONFIG_THREAD_MONITOR)
-
- struct __thread_entry entry;
-
- struct k_thread *next_thread;
- #endif
- #if defined(CONFIG_THREAD_NAME)
-
- char name[CONFIG_THREAD_MAX_NAME_LEN];
- #endif
- #ifdef CONFIG_THREAD_CUSTOM_DATA
-
- void *custom_data;
- #endif
- #ifdef CONFIG_THREAD_USERSPACE_LOCAL_DATA
- struct _thread_userspace_local_data *userspace_local_data;
- #endif
- #if defined(CONFIG_ERRNO) && !defined(CONFIG_ERRNO_IN_TLS)
- #ifndef CONFIG_USERSPACE
-
- int errno_var;
- #endif
- #endif
- #if defined(CONFIG_THREAD_STACK_INFO)
-
- struct _thread_stack_info stack_info;
- #endif
- #if defined(CONFIG_USERSPACE)
-
- struct _mem_domain_info mem_domain_info;
-
- k_thread_stack_t *stack_obj;
-
- void *syscall_frame;
- #endif
- #if defined(CONFIG_THREAD_TIMER)
- sys_dlist_t thread_timer_q;
- #endif
- #if defined(CONFIG_USE_SWITCH)
-
-
- int swap_retval;
-
- void *switch_handle;
- #endif
-
- struct k_heap *resource_pool;
- #if defined(CONFIG_THREAD_LOCAL_STORAGE)
-
- uintptr_t tls;
- #endif
- #ifdef CONFIG_THREAD_RUNTIME_STATS
-
- struct _thread_runtime_stats rt_stats;
- #endif
- #ifdef CONFIG_DEMAND_PAGING_THREAD_STATS
-
- struct k_mem_paging_stats_t paging_stats;
- #endif
-
- struct _thread_arch arch;
- };
- typedef struct k_thread _thread_t;
- typedef struct k_thread *k_tid_t;
- #endif
|