Add handy typedef for struct Semaphore.
[bertos.git] / kern / sem.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2001,2004 Develer S.r.l. (http://www.develer.com/)
5  * Copyright 1999,2000,2001 Bernardo Innocenti <bernie@develer.com>
6  * This file is part of DevLib - See devlib/README for information.
7  * -->
8  *
9  * \brief Mutually exclusive semaphores.
10  *        Shared locking not supported in this implementation.
11  *
12  * \version $Id$
13  *
14  * \author Bernardo Innocenti <bernie@develer.com>
15  */
16
17 /*#*
18  *#* $Log$
19  *#* Revision 1.4  2005/01/22 04:21:20  bernie
20  *#* Add handy typedef for struct Semaphore.
21  *#*
22  *#* Revision 1.3  2004/08/25 14:12:09  rasky
23  *#* Aggiornato il comment block dei log RCS
24  *#*
25  *#* Revision 1.2  2004/06/03 11:27:09  bernie
26  *#* Add dual-license information.
27  *#*
28  *#* Revision 1.1  2004/05/23 17:27:00  bernie
29  *#* Import kern/ subdirectory.
30  *#*
31  *#*/
32
33 #ifndef KERN_SEM_H
34 #define KERN_SEM_H
35
36 #include "compiler.h"
37 #include <mware/list.h>
38
39 /* Fwd decl */
40 struct Process;
41
42
43 typedef struct Semaphore
44 {
45         struct Process *owner;
46         List            wait_queue;
47         int             nest_count;
48 } Semaphore;
49
50 /*!
51  * \name Process synchronization services
52  * \{
53  */
54 void sem_init(struct Semaphore *s);
55 bool sem_attempt(struct Semaphore *s);
56 void sem_obtain(struct Semaphore *s);
57 void sem_release(struct Semaphore *s);
58 /* \} */
59
60 #endif /* KERN_SEM_H */