annotate src/nucleus/smce.c @ 86:425ab6d987f3

src/libsys: pieced together from Citrine
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 20 Jul 2018 20:36:19 +0000
parents 0f80e1e4dce4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 /* Copyright Mentor Graphics Corporation 2002 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 /* All Rights Reserved. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 /* SUBJECT TO LICENSE TERMS. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /* FILE NAME VERSION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /* smce.c Nucleus PLUS 1.14 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 /* COMPONENT */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 /* SM - Semaphore Management */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /* This file contains the error checking routines for the core */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /* functions of the Semaphore component. This permits easy removal */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 /* of error checking logic when it is not needed. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 /* DATA STRUCTURES */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 /* None */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 /* FUNCTIONS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /* SMCE_Create_Semaphore Create a semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /* SMCE_Delete_Semaphore Delete a semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 /* SMCE_Obtain_Semaphore Obtain an instance of a */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 /* semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /* SMCE_Release_Semaphore Release an instance of a */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 /* semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* DEPENDENCIES */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 /* cs_extr.h Common Service functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 /* tc_extr.h Thread Control functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /* sm_extr.h Semaphore functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 /* DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 /* 03-01-1993 Created initial version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /* 04-19-1993 Verified version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 /* 05-15-1993 Corrected comment problem in */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 /* the header, making the new */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* version 1.0a */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 /* 05-15-1993 Verified version 1.0a */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 /* 03-01-1994 Split original error checking */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 /* file and changed function */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 /* interfaces, resulting in */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 /* version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 /* 04-17-1996 updated to version 1.2 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 /* 03-24-1998 Released version 1.3. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 /* 04-17-2002 Released version 1.13m */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 /* 11-07-2002 Released version 1.14 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 #define NU_SOURCE_FILE
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 #include "cs_extr.h" /* Common service functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 #include "tc_extr.h" /* Thread control functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 #include "sm_extr.h" /* Semaphore functions */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 /* FUNCTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 /* SMCE_Create_Semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 /* This function performs error checking on the parameters supplied */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 /* to the create semaphore function. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 /* CALLED BY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 /* Application */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 /* CALLS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 /* SMC_Create_Semaphore Actual semaphore create func.*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 /* INPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 /* semaphore_ptr Semaphore control block ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 /* name Semaphore name */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 /* initial_count Initial semaphore instance */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 /* count */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 /* suspend_type Suspension type */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 /* OUTPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 /* NU_INVALID_SEMAPHORE Semaphore control block ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 /* is NULL */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 /* NU_INVALID_SUSPEND Semaphore suspension is */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 /* invalid */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 /* DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 /* 03-01-1993 Created initial version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 /* 04-19-1993 Verified version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 /* 03-01-1994 Modified function interface, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 /* resulting in version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 STATUS SMCE_Create_Semaphore(NU_SEMAPHORE *semaphore_ptr, CHAR *name,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 UNSIGNED initial_count, OPTION suspend_type)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 SM_SCB *semaphore; /* Semaphore control blk ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 STATUS status; /* Completion status */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 /* Move input semaphore pointer into internal pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 semaphore = (SM_SCB *) semaphore_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 /* Check for a NULL semaphore pointer or an already created semaphore. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 if ((semaphore == NU_NULL) || (semaphore -> sm_id == SM_SEMAPHORE_ID))
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 /* Invalid semaphore control block pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 status = NU_INVALID_SEMAPHORE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 /* Invalid suspension type. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 status = NU_INVALID_SUSPEND;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 /* Call the actual service to create the semaphore. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 status = SMC_Create_Semaphore(semaphore_ptr, name, initial_count,
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 suspend_type);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 /* Return completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 return(status);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 /* FUNCTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 /* SMCE_Delete_Semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 /* This function performs error checking on the parameters supplied */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 /* to the delete semaphore function. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 /* CALLED BY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 /* Application */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 /* CALLS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 /* SMC_Delete_Semaphore Actual delete semaphore func.*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 /* INPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 /* semaphore_ptr Semaphore control block ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 /* OUTPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 /* NU_INVALID_SEMAPHORE Invalid semaphore pointer */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 /* DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 /* 03-01-1993 Created initial version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 /* 04-19-1993 Verified version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 /* 03-01-1994 Modified function interface, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 /* resulting in version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 STATUS SMCE_Delete_Semaphore(NU_SEMAPHORE *semaphore_ptr)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 SM_SCB *semaphore; /* Semaphore control blk ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 STATUS status; /* Completion status */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 /* Move input semaphore pointer into internal pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 semaphore = (SM_SCB *) semaphore_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 /* Determine if the semaphore pointer is valid. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 if ((semaphore) && (semaphore -> sm_id == SM_SEMAPHORE_ID))
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 /* Semaphore pointer is valid, call function to delete it. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 status = SMC_Delete_Semaphore(semaphore_ptr);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 /* Semaphore pointer is invalid, indicate in completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 status = NU_INVALID_SEMAPHORE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 /* Return completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 return(status);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 /* FUNCTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 /* SMCE_Obtain_Semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 /* This function performs error checking on the parameters supplied */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 /* to the obtain semaphore function. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 /* CALLED BY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 /* Application */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 /* CALLS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 /* SMC_Obtain_Semaphore Actual function to obtain an */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 /* instance of the semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 /* TCCE_Suspend_Error Check for illegal suspend */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 /* INPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 /* semaphore_ptr Semaphore control block ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 /* suspend Suspension option if full */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 /* OUTPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 /* NU_INVALID_SEMAPHORE Invalid semaphore pointer */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 /* NU_INVALID_SUSPEND Suspension from non-task */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 /* DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 /* 03-01-1993 Created initial version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 /* 04-19-1993 Verified version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 /* 03-01-1994 Modified function interface, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 /* resulting in version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 STATUS SMCE_Obtain_Semaphore(NU_SEMAPHORE *semaphore_ptr, UNSIGNED suspend)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 SM_SCB *semaphore; /* Semaphore control blk ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 STATUS status; /* Completion status */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 /* Move input semaphore pointer into internal pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 semaphore = (SM_SCB *) semaphore_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 /* Determine if semaphore pointer is invalid. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 if (semaphore == NU_NULL)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 /* Semaphore pointer is invalid, indicate in completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 status = NU_INVALID_SEMAPHORE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 else if (semaphore -> sm_id != SM_SEMAPHORE_ID)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 /* Semaphore pointer is invalid, indicate in completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 status = NU_INVALID_SEMAPHORE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 else if ((suspend) && (TCCE_Suspend_Error()))
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 /* Suspension from an non-task thread. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 status = NU_INVALID_SUSPEND;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 /* Parameters are valid, call actual function. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 status = SMC_Obtain_Semaphore(semaphore_ptr, suspend);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 /* Return the completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 return(status);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 /* FUNCTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 /* SMCE_Release_Semaphore */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 /* DESCRIPTION */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 /* This function performs error checking on the parameters supplied */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 /* to the release semaphore function. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 /* CALLED BY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 /* Application */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 /* CALLS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 /* SMC_Release_Semaphore Actual release semaphore fct.*/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 /* INPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 /* semaphore_ptr Semaphore control block ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 /* OUTPUTS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 /* NU_INVALID_SEMAPHORE Invalid semaphore pointer */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 /* HISTORY */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 /* DATE REMARKS */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 /* 03-01-1993 Created initial version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 /* 04-19-1993 Verified version 1.0 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 /* 03-01-1994 Modified function interface, */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 /* resulting in version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 /* 03-18-1994 Verified version 1.1 */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 /* */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 /*************************************************************************/
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 STATUS SMCE_Release_Semaphore(NU_SEMAPHORE *semaphore_ptr)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 SM_SCB *semaphore; /* Semaphore control blk ptr */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 STATUS status; /* Completion status */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 /* Move input semaphore pointer into internal pointer. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 semaphore = (SM_SCB *) semaphore_ptr;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 /* Determine if semaphore pointer is invalid. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 if (semaphore == NU_NULL)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 /* Semaphore pointer is invalid, indicate in completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 status = NU_INVALID_SEMAPHORE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 else if (semaphore -> sm_id != SM_SEMAPHORE_ID)
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 /* Semaphore pointer is invalid, indicate in completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 status = NU_INVALID_SEMAPHORE;
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 else
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 {
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 /* Parameters are valid, call actual function. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 status = SMC_Release_Semaphore(semaphore_ptr);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 /* Return the completion status. */
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 return(status);
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 }
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376
0f80e1e4dce4 src/nucleus: library C code import from FreeNucleus package
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377