POK
semaphore.h
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #ifdef POK_NEEDS_ARINC653_SEMAPHORE
19 #ifndef APEX_SEMAPHORE
20 #define APEX_SEMAPHORE
21 
22 #ifndef POK_NEEDS_ARINC653_PROCESS
23 #define POK_NEEDS_ARINC653_PROCESS 1
24 #endif
25 
26 #include <arinc653/types.h>
27 #include <arinc653/process.h>
28 
29 /*----------------------------------------------------------------------*/
30 /* */
31 /* SEMAPHORE constant definitions */
32 /* */
33 /*----------------------------------------------------------------------*/
34 /* implementation dependent */
35 /* these values are given as example */
36 /*------------------------------*/
37 /* max nb of semaphores */
38 /*------------------------------*/
39 #define MAX_NUMBER_OF_SEMAPHORES 63
40 /*------------------------------*/
41 /* max semaphore value */
42 /*------------------------------*/
43 #define MAX_SEMAPHORE_VALUE 32767
44 /*----------------------------------------------------------------------*/
45 /* */
46 /* SEMAPHORE type definitions */
47 /* */
48 /*----------------------------------------------------------------------*/
49 /*------------------------------*/
50 /* semaphore ident type */
51 /*------------------------------*/
52 typedef APEX_INTEGER SEMAPHORE_ID_TYPE;
53 /*------------------------------*/
54 /* semaphore value type */
55 /*------------------------------*/
56 typedef APEX_INTEGER SEMAPHORE_VALUE_TYPE;
57 /*------------------------------*/
58 /* semaphore name type */
59 /*------------------------------*/
60 typedef NAME_TYPE SEMAPHORE_NAME_TYPE;
61 /*------------------------------*/
62 /* semaphore status type */
63 /*------------------------------*/
64 typedef
65 struct {
66  SEMAPHORE_VALUE_TYPE CURRENT_VALUE;
67  SEMAPHORE_VALUE_TYPE MAXIMUM_VALUE;
68  WAITING_RANGE_TYPE WAITING_PROCESSES;
70 /*----------------------------------------------------------------------*/
71 /* */
72 /* semaphore management services */
73 /* */
74 /*----------------------------------------------------------------------*/
75 /*----------------------------------------------------------------------*/
76 extern void CREATE_SEMAPHORE (
77  /*IN */ SEMAPHORE_NAME_TYPE SEMAPHORE_NAME,
78  /*IN */ SEMAPHORE_VALUE_TYPE CURRENT_VALUE,
79  /*IN */ SEMAPHORE_VALUE_TYPE MAXIMUM_VALUE,
80  /*IN */ QUEUING_DISCIPLINE_TYPE QUEUING_DISCIPLINE,
81  /*OUT*/ SEMAPHORE_ID_TYPE *SEMAPHORE_ID,
82  /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
83 /*----------------------------------------------------------------------*/
84 extern void WAIT_SEMAPHORE (
85  /*IN */ SEMAPHORE_ID_TYPE SEMAPHORE_ID,
86  /*IN */ SYSTEM_TIME_TYPE TIME_OUT,
87  /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
88 /*----------------------------------------------------------------------*/
89 extern void SIGNAL_SEMAPHORE (
90  /*IN */ SEMAPHORE_ID_TYPE SEMAPHORE_ID,
91  /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
92 /*----------------------------------------------------------------------*/
93 extern void GET_SEMAPHORE_ID (
94  /*IN */ SEMAPHORE_NAME_TYPE SEMAPHORE_NAME,
95  /*OUT*/ SEMAPHORE_ID_TYPE *SEMAPHORE_ID,
96  /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
97 /*----------------------------------------------------------------------*/
98 extern void GET_SEMAPHORE_STATUS (
99  /*IN */ SEMAPHORE_ID_TYPE SEMAPHORE_ID,
100  /*OUT*/ SEMAPHORE_STATUS_TYPE *SEMAPHORE_STATUS,
101  /*OUT*/ RETURN_CODE_TYPE *RETURN_CODE );
102 /*----------------------------------------------------------------------*/
103 #endif
104 #endif