condvar.h File Reference

Header file of file condvar.c. More...

#include "mutex.h"
#include "tqueue.h"
#include "thread.h"

Go to the source code of this file.

Data Structures

struct  cond

Typedefs

typedef cond cond_t

Functions

void cond_init (cond_t *cvar)
 Initialize condition variable.
void cond_destroy (cond_t *cvar)
 Destroys conditional variable.
void cond_signal (cond_t *cvar)
 Unlock one of threads waiting on the condition variable.
void cond_broadcast (cond_t *cvar)
 Unlock all of threads waiting on the condition variable.
void cond_wait (cond_t *cvar, struct mutex *mtx)
 Suspend calling thread on a condition variable waiting for condition Atomically unlocks mutex and suspends calling thread on conditional variable after waking up locks mutex.
int cond_wait_timeout (cond_t *cvar, mutex_t *mtx, const unsigned int usec)
 Atomically unlocks mutex and suspends calling thread at most on \ usec microseconds.


Detailed Description

Header file of file condvar.c.

Conditional variables are implemented as a queue of threads vaiting for the condition, that allows to wakeup them on cond_wait and cond signal calls.

This file is based on Kalisto, Development Kernel copyrighted (c) to Distributed Systems Research Group MFF UK, Czech republic.


Typedef Documentation

typedef struct cond cond_t

define conditional variable to usual notation with .._t


Function Documentation

void cond_broadcast ( cond_t cvar  ) 

Unlock all of threads waiting on the condition variable.

Parameters:
cvar condition variable struct pointer

void cond_destroy ( cond_t cvar  ) 

Destroys conditional variable.

Parameters:
cvar condition variable struct pointer

void cond_init ( cond_t cvar  ) 

Initialize condition variable.

Parameters:
cvar condition variable struct pointer

void cond_signal ( cond_t cvar  ) 

Unlock one of threads waiting on the condition variable.

Parameters:
cvar condition variable struct pointer

void cond_wait ( cond_t cvar,
struct mutex mtx 
)

Suspend calling thread on a condition variable waiting for condition Atomically unlocks mutex and suspends calling thread on conditional variable after waking up locks mutex.

Parameters:
cvar condition variable pointer
mtx mutex pointer

int cond_wait_timeout ( cond_t cvar,
mutex_t mtx,
const unsigned int  usec 
)

Atomically unlocks mutex and suspends calling thread at most on \ usec microseconds.

If 0 msec is wanted thread suspend is ommitted, but the thread yield one times before next mutex lock

Parameters:
cvar condition variable struct pointer
mtx mutex pointer
usec time limit to wait
Returns:
EOK on thread woken up durint the wanted time period, ETIMEDOUT else


Generated on Wed Nov 15 17:25:43 2006 for Kalisto by  doxygen 1.4.7