130#ifdef MODULE_CORE_THREAD_FLAGS
134#include "thread_arch.h"
146#ifdef THREAD_API_INLINED
147#define THREAD_MAYBE_INLINE static inline __attribute__((always_inline))
149#define THREAD_MAYBE_INLINE
152#if defined(DEVELHELP) && !defined(CONFIG_THREAD_NAMES)
159#define CONFIG_THREAD_NAMES
165typedef void *(*thread_task_func_t)(
void *arg);
177#if defined(MODULE_CORE_THREAD_FLAGS) || defined(DOXYGEN)
183#if defined(MODULE_CORE_MSG) || defined(MODULE_CORE_THREAD_FLAGS) \
184 || defined(MODULE_CORE_MBOX) || defined(DOXYGEN)
188#if defined(MODULE_CORE_MSG) || defined(DOXYGEN)
197#if defined(DEVELHELP) || IS_ACTIVE(SCHED_TEST_STACK) \
198 || defined(MODULE_MPU_STACK_GUARD) || defined(DOXYGEN)
201#if defined(CONFIG_THREAD_NAMES) || defined(DOXYGEN)
204#if defined(DEVELHELP) || defined(DOXYGEN)
220#define THREAD_CREATE_SLEEPING (1)
225#define THREAD_AUTO_FREE (2)
233#define THREAD_CREATE_WOUT_YIELD (4)
240#define THREAD_CREATE_NO_STACKTEST (8)
249#define THREAD_CREATE_STACKTEST (0)
337#if defined(MODULE_CORE_THREAD) || DOXYGEN
400 return sched_active_pid;
412 extern volatile thread_t *sched_active_thread;
414 return (
thread_t *)sched_active_thread;
428 void *stack_start,
int stack_size);
455#if defined(MODULE_CORE_THREAD) || DOXYGEN
523#if defined(MODULE_CORE_MSG) || defined(DOXYGEN)
580#if defined(DEVELHELP) || IS_ACTIVE(SCHED_TEST_STACK) \
581 || defined(MODULE_MPU_STACK_GUARD)
610#if defined(DEVELHELP)
639#if defined(CONFIG_THREAD_NAMES)
Circular integer buffer interface.
Common macros and compiler attributes/pragmas configuration.
#define assume(cond)
Behaves like an assert(), but tells the compiler that cond can never be false.
Messaging API for inter process communication.
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.
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 bool thread_has_msg_queue(const thread_t *thread)
Checks if a thread has an initialized message queue.
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.
Thread configuration defines.