]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/dde/include/ddekit/condvar.h
update
[l4.git] / l4 / pkg / dde / include / ddekit / condvar.h
1 #pragma once
2
3 /** \file ddekit/condvar.h */
4
5 /*
6  * This file is part of DDEKit.
7  *
8  * (c) 2006-2010 Bjoern Doebel <doebel@os.inf.tu-dresden.de>
9  *               Christian Helmuth <ch12@os.inf.tu-dresden.de>
10  *               Thomas Friebel <tf13@os.inf.tu-dresden.de>
11  *     economic rights: Technische Universitaet Dresden (Germany)
12  *
13  * This file is part of TUD:OS and distributed under the terms of the
14  * GNU General Public License 2.
15  * Please see the COPYING-GPL-2 file for details.
16  */
17
18 #include <l4/dde/ddekit/lock.h>
19 #include <l4/sys/compiler.h>
20
21 EXTERN_C_BEGIN
22
23 struct ddekit_condvar;
24 typedef struct ddekit_condvar ddekit_condvar_t;
25
26 /** Initialize conditional variable.
27  *
28  * \ingroup DDEKit_synchronization
29  */
30 ddekit_condvar_t * ddekit_condvar_init(void);
31
32 /** Uninitialize conditional variable. 
33  *
34  * \ingroup DDEKit_synchronization
35  */
36 void ddekit_condvar_deinit(ddekit_condvar_t *cvp);
37
38 /** Wait on a conditional variable.
39  *
40  * \ingroup DDEKit_synchronization
41  */
42 void ddekit_condvar_wait(ddekit_condvar_t *cvp, ddekit_lock_t *mp);
43
44 /** Wait on a conditional variable at most until a timeout expires.
45  *
46  * \ingroup DDEKit_synchronization
47  *
48  * \param cvp    pointer to condvar
49  * \param mp     lock
50  * \param timo   timeout in ms
51  *
52  * \return 0     success
53  * \return !=0   timeout
54  */
55 int  ddekit_condvar_wait_timed(ddekit_condvar_t *cvp, ddekit_lock_t *mp, int timo);
56
57 /** Send signal to the next one waiting for condvar.
58  *
59  * \ingroup DDEKit_synchronization
60  */
61 void ddekit_condvar_signal(ddekit_condvar_t *cvp);
62
63 /** Send signal to all threads waiting for condvar.
64  *
65  * \ingroup DDEKit_synchronization
66  */
67 void ddekit_condvar_broadcast(ddekit_condvar_t *cvp);
68
69 EXTERN_C_END