Barrelfish
Functions
thread_sync.c File Reference

Thread synchronisation primitives. More...

Functions

void thread_cond_init (struct thread_cond *cond)
 Initialise a condition variable. More...
 
void thread_cond_wait (struct thread_cond *cond, struct thread_mutex *mutex)
 Wait for 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_mutex_init (struct thread_mutex *mutex)
 Initialise a mutex. More...
 
void thread_mutex_lock (struct thread_mutex *mutex)
 Lock a mutex. More...
 
void thread_mutex_lock_nested (struct thread_mutex *mutex)
 Lock a mutex. More...
 
bool thread_mutex_trylock (struct thread_mutex *mutex)
 Try to lock a mutex. More...
 
struct threadthread_mutex_unlock_disabled (dispatcher_handle_t handle, struct thread_mutex *mutex)
 Unlock a mutex, while disabled. More...
 
void thread_mutex_unlock (struct thread_mutex *mutex)
 Unlock a mutex. More...
 

Detailed Description

Thread synchronisation primitives.

Function Documentation

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.

Parameters
condCondition variable pointer
void thread_cond_init ( struct thread_cond *  cond)

Initialise a condition variable.

Parameters
condCondition 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.

Parameters
condCondition 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'.

Parameters
condCondition variable pointer
mutexOptional pointer to mutex to unlock.
void thread_mutex_init ( struct thread_mutex *  mutex)

Initialise a mutex.

Parameters
mutexMutex 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.

Parameters
mutexMutex 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.

Parameters
mutexMutex 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.

Parameters
mutexMutex pointer
Returns
true if lock acquired, false otherwise
void thread_mutex_unlock ( struct thread_mutex *  mutex)

Unlock a mutex.

This unlocks the given mutex.

Parameters
mutexMutex 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.

Parameters
dispDispatcher pointer
mutexMutex pointer
Returns
Pointer to thread to be woken on foreign dispatcher