thread.h File Reference

Threading API. More...

Detailed Description

Threading API.

Kaspar Schleiser

Definition in file thread.h.

#include "clist.h"
#include "cib.h"
#include "msg.h"
#include "cpu_conf.h"
#include "sched.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...


 This global macro enable storage of thread names to help developers. More...
 A reasonable default stack size that will suffice most smaller tasks. More...
 Size of the idle task's stack in bytes. More...
 Size of the task's printf stack in bytes. More...
 Size of the main task's stack in bytes. More...
 Large stack size.
 Medium stack size.
 Small stack size.
 Tiny stack size.
#define THREAD_STACKSIZE_MINIMUM   (sizeof(thread_t))
 Minimum stack size.
 Least priority a thread can have.
 Priority of the idle thread.
 Priority of the main thread. More...


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


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. More...
static thread_tthread_get_unchecked (kernel_pid_t pid)
 Retrieve a thread control block by PID. More...
static thread_tthread_get (kernel_pid_t pid)
 Retrieve a thread control block by PID. More...
thread_status_t thread_getstatus (kernel_pid_t pid)
 Returns the status of a process. More...
void thread_sleep (void)
 Puts the current thread into sleep mode. More...
void thread_yield (void)
 Lets current thread yield. More...
void thread_yield_higher (void)
 Lets current thread yield in favor of a higher prioritized thread. More...
void thread_zombify (void)
 Puts the current thread into zombie state. More...
int thread_kill_zombie (kernel_pid_t pid)
 Terminates zombie thread. More...
int thread_wakeup (kernel_pid_t pid)
 Wakes up a sleeping thread. More...
static kernel_pid_t thread_getpid (void)
 Returns the process ID of the currently running thread. More...
static thread_tthread_get_active (void)
 Returns a pointer to the Thread Control Block of the currently running thread. More...
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. More...
void thread_add_to_list (list_node_t *list, thread_t *thread)
 Add thread to list, sorted by priority (internal) More...
const char * thread_getname (kernel_pid_t pid)
 Returns the name of a process. More...
uintptr_t thread_measure_stack_free (const char *stack)
 Measures the stack usage of a stack. More...
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. More...

Optional flags for controlling a threads initial state

 Set the new thread to sleeping. More...
#define THREAD_AUTO_FREE   (2)
 Currently not implemented.
 Do not automatically call thread_yield() after creation: the newly created thread might not run immediately. More...
 Write markers into the thread's stack to measure stack usage (for debugging and profiling purposes)