summaryrefslogtreecommitdiffstats
path: root/cpukit/itron/include/itronsys/semaphore.h
blob: c149012dad96a0e72bf61f624a85a2eb558c69f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#ifndef __ITRON_SEMAPHORE_h_
#define __ITRON_SEMAPHORE_h_

#ifdef __cplusplus
extern "C" {
#endif

/*
 *  Create Semaphore (cre_sem) Structure
 */

typedef struct t_csem {
  VP    exinf;    /* extended information */
  ATR   sematr;   /* semaphore attributes */
  /* Following is the extended function for [level X]. */
  INT   isemcnt;   /* initial semaphore count */
  INT   maxsem;    /* maximum semaphore count */
  /* additional information may be included depending on the implementation */
} T_CSEM;

/*
 *  sematr - Semaphore Attribute Values
 */

#define TA_TFIFO   0x00   /* waiting tasks are handled by FIFO */
#define TA_TPRI    0x01   /* waiting tasks are handled by priority */

#define _ITRON_SEMAPHORE_UNUSED_ATTRIBUTES ~(TA_TPRI)

/*
 *  Reference Semaphore (ref_sem) Structure
 */

typedef struct t_rsem {
  VP      exinf;    /* extended information */
  BOOL_ID wtsk;     /* indicates whether or not there is a waiting task */
  INT     semcnt;   /* current semaphore count */
  /* additional information may be included depending on the implementation */
} T_RSEM;

/*
 *  Semaphore Functions
 */

/*
 *  cre_sem - Create Semaphore
 */

ER cre_sem(
  ID semid,
  T_CSEM *pk_csem
);

/*
 *  del_sem - Delete Semaphore
 */

ER del_sem(
  ID semid
);

/*
 *  sig_sem - Signal Semaphore
 */

ER sig_sem(
  ID semid
);

/*
 *  wai_sem - Wait on Semaphore 
 */

ER wai_sem(
  ID semid
);

/*
 *  preq_sem - Poll and Request Semaphore
 */

ER preq_sem(
  ID semid
);

/*
 *  twai_sem - Wait on Semaphore with Timeout
 */

ER twai_sem(
  ID semid,
  TMO tmout
);

/*
 *  ref_sem - Reference Semaphore Status
 */

ER ref_sem(
  ID      semid,
  T_RSEM *pk_rsem
);

#ifdef __cplusplus
}
#endif

#endif
/* end of include file */