Loading...
Searching...
No Matches
thread.h File Reference

Threading API. More...

Detailed Description

Threading API.

Author
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e

Definition in file thread.h.

#include "clist.h"
#include "cib.h"
#include "msg.h"
#include "sched.h"
#include "thread_config.h"
#include "thread_arch.h"
+ Include dependency graph for thread.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _thread
 thread_t holds thread's context data. More...
 

Macros

#define THREAD_MAYBE_INLINE
 Macro definition to inline some of the platform specific implementations.
 
#define CONFIG_THREAD_NAMES
 This global macro enable storage of thread names to help developers.
 

Typedefs

typedef void *(* thread_task_func_t) (void *arg)
 Prototype for a thread entry function.
 

Functions

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.
 
static thread_tthread_get_unchecked (kernel_pid_t pid)
 Retrieve a thread control block by PID.
 
static thread_tthread_get (kernel_pid_t pid)
 Retrieve a thread control block by PID.
 
thread_status_t thread_getstatus (kernel_pid_t pid)
 Returns the status of a process.
 
void thread_sleep (void)
 Puts the current thread into sleep mode.
 
void thread_yield (void)
 Lets current thread yield.
 
THREAD_MAYBE_INLINE void thread_yield_higher (void)
 Lets current thread yield in favor of a higher prioritized thread.
 
void thread_zombify (void)
 Puts the current thread into zombie state.
 
int thread_kill_zombie (kernel_pid_t pid)
 Terminates zombie thread.
 
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.
 
static thread_tthread_get_active (void)
 Returns a pointer to the Thread Control Block 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.
 
void thread_add_to_list (list_node_t *list, thread_t *thread)
 Add thread to list, sorted by priority (internal)
 
const char * thread_getname (kernel_pid_t pid)
 Returns the name of a process.
 
uintptr_t measure_stack_free_internal (const char *stack, size_t size)
 Measures the stack usage of a stack.
 
int thread_isr_stack_usage (void)
 Get the number of bytes used on the ISR stack.
 
void * thread_isr_stack_pointer (void)
 Get the current ISR stack pointer.
 
void * thread_isr_stack_start (void)
 Get the start of the ISR stack.
 
void thread_stack_print (void)
 Print the current stack to stdout.
 
void thread_print_stack (void)
 Prints human readable, ps-like thread information for debugging purposes.
 
static int thread_has_msg_queue (const volatile struct _thread *thread)
 Checks if a thread has an initialized message queue.
 
static thread_status_t thread_get_status (const thread_t *thread)
 Get a thread's status.
 
static uint8_t thread_get_priority (const thread_t *thread)
 Get a thread's priority.
 
static bool thread_is_active (const thread_t *thread)
 Returns if a thread is active (currently running or waiting to be scheduled)
 
const char * thread_state_to_string (thread_status_t state)
 Convert a thread state code to a human readable string.
 
static void * thread_get_stackstart (const thread_t *thread)
 Get start address (lowest) of a thread's stack.
 
static void * thread_get_sp (const thread_t *thread)
 Get stored Stack Pointer of thread.
 
static size_t thread_get_stacksize (const thread_t *thread)
 Get size of a thread's stack.
 
static kernel_pid_t thread_getpid_of (const thread_t *thread)
 Get PID of thread.
 
static const char * thread_get_name (const thread_t *thread)
 Get name of thread.
 
static uintptr_t thread_measure_stack_free (const thread_t *thread)
 Measures the stack usage of a stack.
 

Optional flags for controlling a threads initial state

#define THREAD_CREATE_SLEEPING   (1)
 Set the new thread to sleeping.
 
#define THREAD_AUTO_FREE   (2)
 Currently not implemented.
 
#define THREAD_CREATE_WOUT_YIELD   (4)
 Do not automatically call thread_yield() after creation: the newly created thread might not run immediately.
 
#define THREAD_CREATE_NO_STACKTEST   (8)
 Never write markers into the thread's stack to measure stack usage.
 
#define THREAD_CREATE_STACKTEST   (0)
 Legacy flag kept for compatibility.