1 | /** |
---|
2 | * @file itronsys/semaphore.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * COPYRIGHT (c) 1989-1999. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.rtems.com/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef __ITRON_SEMAPHORE_h_ |
---|
17 | #define __ITRON_SEMAPHORE_h_ |
---|
18 | |
---|
19 | #ifdef __cplusplus |
---|
20 | extern "C" { |
---|
21 | #endif |
---|
22 | |
---|
23 | /* |
---|
24 | * Create Semaphore (cre_sem) Structure |
---|
25 | */ |
---|
26 | |
---|
27 | typedef struct t_csem { |
---|
28 | VP exinf; /* extended information */ |
---|
29 | ATR sematr; /* semaphore attributes */ |
---|
30 | /* Following is the extended function for [level X]. */ |
---|
31 | INT isemcnt; /* initial semaphore count */ |
---|
32 | INT maxsem; /* maximum semaphore count */ |
---|
33 | /* additional information may be included depending on the implementation */ |
---|
34 | } T_CSEM; |
---|
35 | |
---|
36 | /* |
---|
37 | * sematr - Semaphore Attribute Values |
---|
38 | */ |
---|
39 | |
---|
40 | #define TA_TFIFO 0x00 /* waiting tasks are handled by FIFO */ |
---|
41 | #define TA_TPRI 0x01 /* waiting tasks are handled by priority */ |
---|
42 | |
---|
43 | #define _ITRON_SEMAPHORE_UNUSED_ATTRIBUTES ~(TA_TPRI) |
---|
44 | |
---|
45 | /* |
---|
46 | * Reference Semaphore (ref_sem) Structure |
---|
47 | */ |
---|
48 | |
---|
49 | typedef struct t_rsem { |
---|
50 | VP exinf; /* extended information */ |
---|
51 | BOOL_ID wtsk; /* indicates whether or not there is a waiting task */ |
---|
52 | INT semcnt; /* current semaphore count */ |
---|
53 | /* additional information may be included depending on the implementation */ |
---|
54 | } T_RSEM; |
---|
55 | |
---|
56 | /* |
---|
57 | * Semaphore Functions |
---|
58 | */ |
---|
59 | |
---|
60 | /* |
---|
61 | * cre_sem - Create Semaphore |
---|
62 | */ |
---|
63 | |
---|
64 | ER cre_sem( |
---|
65 | ID semid, |
---|
66 | T_CSEM *pk_csem |
---|
67 | ); |
---|
68 | |
---|
69 | /* |
---|
70 | * del_sem - Delete Semaphore |
---|
71 | */ |
---|
72 | |
---|
73 | ER del_sem( |
---|
74 | ID semid |
---|
75 | ); |
---|
76 | |
---|
77 | /* |
---|
78 | * sig_sem - Signal Semaphore |
---|
79 | */ |
---|
80 | |
---|
81 | ER sig_sem( |
---|
82 | ID semid |
---|
83 | ); |
---|
84 | |
---|
85 | /* |
---|
86 | * wai_sem - Wait on Semaphore |
---|
87 | */ |
---|
88 | |
---|
89 | ER wai_sem( |
---|
90 | ID semid |
---|
91 | ); |
---|
92 | |
---|
93 | /* |
---|
94 | * preq_sem - Poll and Request Semaphore |
---|
95 | */ |
---|
96 | |
---|
97 | ER preq_sem( |
---|
98 | ID semid |
---|
99 | ); |
---|
100 | |
---|
101 | /* |
---|
102 | * twai_sem - Wait on Semaphore with Timeout |
---|
103 | */ |
---|
104 | |
---|
105 | ER twai_sem( |
---|
106 | ID semid, |
---|
107 | TMO tmout |
---|
108 | ); |
---|
109 | |
---|
110 | /* |
---|
111 | * ref_sem - Reference Semaphore Status |
---|
112 | */ |
---|
113 | |
---|
114 | ER ref_sem( |
---|
115 | ID semid, |
---|
116 | T_RSEM *pk_rsem |
---|
117 | ); |
---|
118 | |
---|
119 | #ifdef __cplusplus |
---|
120 | } |
---|
121 | #endif |
---|
122 | |
---|
123 | #endif |
---|
124 | /* end of include file */ |
---|