128#ifdef MODULE_CORE_THREAD_FLAGS
132#include "thread_arch.h"
144#ifdef THREAD_API_INLINED
145#define THREAD_MAYBE_INLINE static inline __attribute__((always_inline))
147#define THREAD_MAYBE_INLINE
150#if defined(DEVELHELP) && !defined(CONFIG_THREAD_NAMES)
157#define CONFIG_THREAD_NAMES
163typedef void *(*thread_task_func_t)(
void *arg);
175#if defined(MODULE_CORE_THREAD_FLAGS) || defined(DOXYGEN)
181#if defined(MODULE_CORE_MSG) || defined(MODULE_CORE_THREAD_FLAGS) \
182 || defined(MODULE_CORE_MBOX) || defined(DOXYGEN)
186#if defined(MODULE_CORE_MSG) || defined(DOXYGEN)
195#if defined(DEVELHELP) || IS_ACTIVE(SCHED_TEST_STACK) \
196 || defined(MODULE_MPU_STACK_GUARD) || defined(DOXYGEN)
199#if defined(CONFIG_THREAD_NAMES) || defined(DOXYGEN)
202#if defined(DEVELHELP) || defined(DOXYGEN)
218#define THREAD_CREATE_SLEEPING (1)
223#define THREAD_AUTO_FREE (2)
231#define THREAD_CREATE_WOUT_YIELD (4)
238#define THREAD_CREATE_NO_STACKTEST (8)
247#define THREAD_CREATE_STACKTEST (0)
334#if defined(MODULE_CORE_THREAD) || DOXYGEN
397 return sched_active_pid;
409 extern volatile thread_t *sched_active_thread;
411 return (
thread_t *)sched_active_thread;
425 void *stack_start,
int stack_size);
452#if defined(MODULE_CORE_THREAD) || DOXYGEN
516#if defined(MODULE_CORE_MSG) || defined(DOXYGEN)
573#if defined(DEVELHELP) || IS_ACTIVE(SCHED_TEST_STACK) \
574 || defined(MODULE_MPU_STACK_GUARD)
603#if defined(DEVELHELP)
632#if defined(CONFIG_THREAD_NAMES)
Circular integer buffer interface.
static int pid_is_valid(kernel_pid_t pid)
Determine if the given pid is valid.
int16_t kernel_pid_t
Unique process identifier.
volatile thread_t * sched_threads[KERNEL_PID_LAST+1]
Thread table.
#define STATUS_ON_RUNQUEUE
to check if on run queue: st >= STATUS_ON_RUNQUEUE
uint16_t thread_flags_t
Type definition of thread_flags_t.
void thread_stack_print(void)
Print the current stack to stdout.
uintptr_t measure_stack_free_internal(const char *stack, size_t size)
Measures the stack usage of a stack.
thread_status_t thread_getstatus(kernel_pid_t pid)
Returns the status of a process.
const char * thread_state_to_string(thread_status_t state)
Convert a thread state code to a human readable string.
static uint8_t thread_get_priority(const thread_t *thread)
Get a thread's priority.
static size_t thread_get_stacksize(const thread_t *thread)
Get size of a thread's stack.
void *(* thread_task_func_t)(void *arg)
Prototype for a thread entry function.
static const char * thread_get_name(const thread_t *thread)
Get name of thread.
static thread_t * thread_get_active(void)
Returns a pointer to the Thread Control Block of the currently running thread.
void thread_add_to_list(list_node_t *list, thread_t *thread)
Add thread to list, sorted by priority (internal)
static uintptr_t thread_measure_stack_free(const thread_t *thread)
Measures the stack usage of a stack.
void thread_zombify(void)
Puts the current thread into zombie state.
static int thread_has_msg_queue(const volatile struct _thread *thread)
Checks if a thread has an initialized message queue.
kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority, int flags, thread_task_func_t task_func, void *arg, const char *name)
Creates a new thread.
THREAD_MAYBE_INLINE void thread_yield_higher(void)
Lets current thread yield in favor of a higher prioritized thread.
void * thread_isr_stack_pointer(void)
Get the current ISR stack pointer.
int thread_kill_zombie(kernel_pid_t pid)
Terminates zombie thread.
void thread_sleep(void)
Puts the current thread into sleep mode.
static void * thread_get_stackstart(const thread_t *thread)
Get start address (lowest) of a thread's stack.
static thread_t * thread_get_unchecked(kernel_pid_t pid)
Retrieve a thread control block by PID.
const char * thread_getname(kernel_pid_t pid)
Returns the name of a process.
void thread_yield(void)
Lets current thread yield.
int thread_wakeup(kernel_pid_t pid)
Wakes up a sleeping thread.
static kernel_pid_t thread_getpid(void)
Returns the process ID of the currently running thread.
char * thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size)
Gets called upon thread creation to set CPU registers.
static bool thread_is_active(const thread_t *thread)
Returns if a thread is active (currently running or waiting to be scheduled)
int thread_isr_stack_usage(void)
Get the number of bytes used on the ISR stack.
static thread_status_t thread_get_status(const thread_t *thread)
Get a thread's status.
static thread_t * thread_get(kernel_pid_t pid)
Retrieve a thread control block by PID.
static void * thread_get_sp(const thread_t *thread)
Get stored Stack Pointer of thread.
void thread_print_stack(void)
Prints human readable, ps-like thread information for debugging purposes.
void * thread_isr_stack_start(void)
Get the start of the ISR stack.
#define THREAD_MAYBE_INLINE
Macro definition to inline some of the platform specific implementations.
static kernel_pid_t thread_getpid_of(const thread_t *thread)
Get PID of thread.
Scheduler API definition.
thread_t holds thread's context data.
char * sp
thread's stack pointer
char * stack_start
thread's stack start address
cib_t msg_queue
index of this [thread's message queue] (thread_t::msg_array), if any
thread_flags_t flags
currently set flags
list_node_t msg_waiters
threads waiting for their message to be delivered to this thread (i.e.
thread_status_t status
thread's status
msg_t * msg_array
memory holding messages sent to this thread's message queue
uint8_t priority
thread's priority
int stack_size
thread's stack size
const char * name
thread's name
clist_node_t rq_entry
run queue entry
void * wait_data
used by msg, mbox and thread flags
kernel_pid_t pid
thread's process id
circular integer buffer structure
Describes a message object which can be sent between threads.
Definitions for parsing and composition of DNS messages.
Thread configuration defines.