Barrelfish
|
Threads. More...
Macros | |
#define | THREADS_DEFAULT_STACK_BYTES (64 * 1024) |
Default size of a thread's stack. | |
Functions | |
struct thread * | thread_create (thread_func_t start_func, void *data) |
Creates a new thread, and makes it runnable. More... | |
struct thread * | thread_create_varstack (thread_func_t start_func, void *arg, size_t stacksize) |
Creates a new thread, and makes it runnable. More... | |
void | thread_yield (void) |
Yield the calling thread. More... | |
void | thread_yield_dispatcher (struct capref endpoint) |
Yield both the calling thread, and the dispatcher to another domain. More... | |
void | thread_exit (int status) |
Terminate the calling thread. | |
struct thread * | thread_self (void) |
Returns the thread pointer to the currently-running thread. | |
errval_t | thread_join (struct thread *thread, int *retval) |
Wait for termination of another thread. More... | |
errval_t | thread_detach (struct thread *thread) |
Detach a thread. Free its state when it terminates. More... | |
void | thread_pause (struct thread *thread) |
Pause (suspend execution of) the given thread. More... | |
void | thread_pause_and_capture_state (struct thread *thread, arch_registers_state_t **ret_regs, arch_registers_fpu_state_t **ret_fpuregs) |
Pause (suspend execution of) the given thread, and optionally capture its register state. More... | |
void | thread_resume (struct thread *thread) |
Resume execution of a thread previously suspended by thread_pause() | |
void | thread_mutex_init (struct thread_mutex *mutex) |
Initialise a mutex. More... | |
void | thread_mutex_lock (struct thread_mutex *mutex) |
Lock a mutex. More... | |
bool | thread_mutex_trylock (struct thread_mutex *mutex) |
Try to lock a mutex. More... | |
void | thread_mutex_lock_nested (struct thread_mutex *mutex) |
Lock a mutex. More... | |
void | thread_mutex_unlock (struct thread_mutex *mutex) |
Unlock a mutex. More... | |
struct thread * | thread_mutex_unlock_disabled (dispatcher_handle_t handle, struct thread_mutex *mutex) |
Unlock a mutex, while disabled. More... | |
void | thread_cond_init (struct thread_cond *cond) |
Initialise a condition variable. More... | |
void | thread_cond_signal (struct thread_cond *cond) |
Signal a condition variable. More... | |
void | thread_cond_broadcast (struct thread_cond *cond) |
Broadcast signal a condition variable. More... | |
void | thread_cond_wait (struct thread_cond *cond, struct thread_mutex *mutex) |
Wait for a condition variable. More... | |
void | thread_set_tls (void *) |
Set old-style thread-local storage pointer. More... | |
void * | thread_get_tls (void) |
Return old-style thread-local storage pointer. More... | |
void | thread_set_local_trigger (struct waitset_chanstate *trigger) |
Set/get a local trigger for currently processed event channel. | |
void | thread_store_recv_slot (struct capref recv_slot) |
Store receive slot provided by rpc in thread state. | |
void | thread_set_status (int status) |
Set a thread's exit status. More... | |
Threads.
void thread_cond_broadcast | ( | struct thread_cond * | cond | ) |
Broadcast signal a condition variable.
This function signals the condition variable, and wakes up all threads waiting on it.
cond | Condition variable pointer |
void thread_cond_init | ( | struct thread_cond * | cond | ) |
Initialise a condition variable.
cond | Condition variable pointer |
void thread_cond_signal | ( | struct thread_cond * | cond | ) |
Signal a condition variable.
This function signals the condition variable, and wakes up one thread waiting on it.
cond | Condition variable pointer |
void thread_cond_wait | ( | struct thread_cond * | cond, |
struct thread_mutex * | mutex | ||
) |
Wait for a condition variable.
This function waits for the given condition variable to be signalled (through thread_cond_signal() or thread_cond_broadcast()) before returning, while atomically unlocking the mutex pointed to by 'mutex'.
cond | Condition variable pointer |
mutex | Optional pointer to mutex to unlock. |
struct thread* thread_create | ( | thread_func_t | start_func, |
void * | arg | ||
) |
Creates a new thread, and makes it runnable.
start_func | Function to run on the new thread |
arg | Argument to pass to function |
struct thread* thread_create_varstack | ( | thread_func_t | start_func, |
void * | arg, | ||
size_t | stacksize | ||
) |
Creates a new thread, and makes it runnable.
start_func | Function to run on the new thread |
arg | Argument to pass to function |
stacksize | Size of stack, in bytes |
errval_t thread_detach | ( | struct thread * | thread | ) |
Detach a thread. Free its state when it terminates.
thread | Pointer to thread to detach |
void* thread_get_tls | ( | void | ) |
Return old-style thread-local storage pointer.
errval_t thread_join | ( | struct thread * | thread, |
int * | retval | ||
) |
Wait for termination of another thread.
thread | Pointer to thread to wait for |
retval | Pointer to variable to hold return value of thread, or NULL |
void thread_mutex_init | ( | struct thread_mutex * | mutex | ) |
Initialise a mutex.
mutex | Mutex pointer |
void thread_mutex_lock | ( | struct thread_mutex * | mutex | ) |
Lock a mutex.
This blocks until the given mutex is unlocked, and then atomically locks it.
mutex | Mutex pointer |
void thread_mutex_lock_nested | ( | struct thread_mutex * | mutex | ) |
Lock a mutex.
This blocks until the given mutex is unlocked, and then atomically locks it.
mutex | Mutex pointer |
bool thread_mutex_trylock | ( | struct thread_mutex * | mutex | ) |
Try to lock a mutex.
If the given mutex is unlocked, this atomically locks it and returns true, otherwise it returns false immediately.
mutex | Mutex pointer |
void thread_mutex_unlock | ( | struct thread_mutex * | mutex | ) |
Unlock a mutex.
This unlocks the given mutex.
mutex | Mutex pointer |
struct thread* thread_mutex_unlock_disabled | ( | dispatcher_handle_t | handle, |
struct thread_mutex * | mutex | ||
) |
Unlock a mutex, while disabled.
This function unlocks the given mutex. It may only be called while disabled.
disp | Dispatcher pointer |
mutex | Mutex pointer |
void thread_pause | ( | struct thread * | thread | ) |
Pause (suspend execution of) the given thread.
The thread will not be run, until a subsequent call to thread_resume()
void thread_pause_and_capture_state | ( | struct thread * | thread, |
arch_registers_state_t ** | ret_regs, | ||
arch_registers_fpu_state_t ** | ret_fpuregs | ||
) |
Pause (suspend execution of) the given thread, and optionally capture its register state.
The thread will not be run, until a subsequent call to thread_resume()
void thread_set_status | ( | int | status | ) |
Set a thread's exit status.
status | The status. |
void thread_set_tls | ( | void * | p | ) |
Set old-style thread-local storage pointer.
p | User's pointer |
void thread_yield | ( | void | ) |
Yield the calling thread.
Switches to the next runnable thread in this dispatcher, or if none is available, yields the dispatcher.
void thread_yield_dispatcher | ( | struct capref | endpoint | ) |
Yield both the calling thread, and the dispatcher to another domain.
endpoint | Endpoint cap to which we wish to yield, or #CAP_NULL for an undirected yield |
Yields the dispatcher, optionally to another specified dispatcher.