1 | @c |
---|
2 | @c This is the chapter from the RTEMS ITRON User's Guide that |
---|
3 | @c documents the services provided by the semaphore |
---|
4 | @c manager. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Semaphore Manager |
---|
10 | |
---|
11 | @section Introduction |
---|
12 | |
---|
13 | The semaphore manager provides functions to allocate, delete, and |
---|
14 | control counting semaphores. |
---|
15 | |
---|
16 | The services provided by the semaphore manager are: |
---|
17 | |
---|
18 | @itemize @bullet |
---|
19 | @item @code{cre_sem} - Create Semaphore |
---|
20 | @item @code{del_sem} - Delete Semaphore |
---|
21 | @item @code{sig_sem} - Signal Semaphore |
---|
22 | @item @code{wai_sem} - Wait on Semaphore |
---|
23 | @item @code{preq_sem} - Poll and Request Semaphore |
---|
24 | @item @code{twai_sem} - Wait on Semaphore with Timeout |
---|
25 | @item @code{ref_sem} - Reference Semaphore Status |
---|
26 | @end itemize |
---|
27 | |
---|
28 | @section Background |
---|
29 | |
---|
30 | @subsection Theory |
---|
31 | |
---|
32 | Semaphores are used for synchronization and mutual exclusion by indicating |
---|
33 | the availability and number of resources. The task (the task which is |
---|
34 | returning resources) notifying other tasks of an event increases the number |
---|
35 | of resources held by the semaphore by one. The task (the task which |
---|
36 | will obtain resources) waiting for the event decreases the number of |
---|
37 | resources held by the semaphore by one. If the number of resources held by a |
---|
38 | semaphore is insufficient (namely 0), the task requiring resources will |
---|
39 | wait until the next time resources are returned to the semaphore. If there is |
---|
40 | more than one task waiting for a semaphore, the tasks will be placed in the |
---|
41 | queue. |
---|
42 | |
---|
43 | |
---|
44 | @subsection T_CSEM Structure |
---|
45 | |
---|
46 | The T_CSEM structure is used to define the characteristics of a semaphore |
---|
47 | and passed an as argument to the @code{cre_sem} service. The structure |
---|
48 | is defined as follows: |
---|
49 | |
---|
50 | @example |
---|
51 | @group |
---|
52 | /* |
---|
53 | * Create Semaphore (cre_sem) Structure |
---|
54 | */ |
---|
55 | |
---|
56 | typedef struct t_csem @{ |
---|
57 | VP exinf; /* extended information */ |
---|
58 | ATR sematr; /* semaphore attributes */ |
---|
59 | /* Following is the extended function for [level X]. */ |
---|
60 | INT isemcnt; /* initial semaphore count */ |
---|
61 | INT maxsem; /* maximum semaphore count */ |
---|
62 | /* additional information may be included depending on the implementation */ |
---|
63 | @} T_CSEM; |
---|
64 | |
---|
65 | /* |
---|
66 | * sematr - Semaphore Attribute Values |
---|
67 | */ |
---|
68 | |
---|
69 | #define TA_TFIFO 0x00 /* waiting tasks are handled by FIFO */ |
---|
70 | #define TA_TPRI 0x01 /* waiting tasks are handled by priority */ |
---|
71 | |
---|
72 | @end group |
---|
73 | @end example |
---|
74 | |
---|
75 | where the meaning of each field is: |
---|
76 | |
---|
77 | @table @b |
---|
78 | @item exinf |
---|
79 | is for any extended information that the implementation may define. |
---|
80 | This implementation does not use this field. |
---|
81 | |
---|
82 | @item sematr |
---|
83 | is the attributes for this semaphore. The only attributed |
---|
84 | which can be specified is whether tasks wait in FIFO (@code{TA_TFIFO}) |
---|
85 | or priority (@code{TA_TPRI}) order. |
---|
86 | |
---|
87 | @item isemcnt |
---|
88 | is the initial count of the semaphore. |
---|
89 | |
---|
90 | @item maxsem |
---|
91 | is the maximum count the semaphore may have. It places an upper |
---|
92 | limit on the value taken by the semaphore. |
---|
93 | |
---|
94 | @end table |
---|
95 | |
---|
96 | @subsection Building a Semaphore's Attribute Set |
---|
97 | |
---|
98 | In general, an attribute set is built by a bitwise OR |
---|
99 | of the desired attribute components. The following table lists |
---|
100 | the set of valid semaphore attributes: |
---|
101 | |
---|
102 | @itemize @bullet |
---|
103 | @item @code{TA_TFIFO} - tasks wait by FIFO |
---|
104 | |
---|
105 | @item @code{TA_TPRI} - tasks wait by priority |
---|
106 | |
---|
107 | @end itemize |
---|
108 | |
---|
109 | Attribute values are specifically designed to be |
---|
110 | mutually exclusive, therefore bitwise OR and addition operations |
---|
111 | are equivalent as long as each attribute appears exactly once in |
---|
112 | the component list. |
---|
113 | |
---|
114 | @subsection T_RSEM Structure |
---|
115 | |
---|
116 | The T_RSEM structure is filled in by the @code{ref_sem} service with |
---|
117 | status and state information on a semaphore. The structure |
---|
118 | is defined as follows: |
---|
119 | |
---|
120 | @example |
---|
121 | @group |
---|
122 | /* |
---|
123 | * Reference Semaphore (ref_sem) Structure |
---|
124 | */ |
---|
125 | |
---|
126 | typedef struct t_rsem @{ |
---|
127 | VP exinf; /* extended information */ |
---|
128 | BOOL_ID wtsk; /* indicates whether or not there is a waiting task */ |
---|
129 | INT semcnt; /* current semaphore count */ |
---|
130 | /* additional information may be included depending on the implementation */ |
---|
131 | @} T_RSEM; |
---|
132 | @end group |
---|
133 | @end example |
---|
134 | |
---|
135 | @table @b |
---|
136 | |
---|
137 | @item exinf |
---|
138 | is for any extended information that the implementation may define. |
---|
139 | This implementation does not use this field. |
---|
140 | |
---|
141 | @item wtsk |
---|
142 | is TRUE when there is one or more task waiting on the semaphore. |
---|
143 | It is FALSE if no tasks are currently waiting. The meaning of this |
---|
144 | field is allowed to vary between ITRON implementations. It may have |
---|
145 | the ID of a waiting task, the number of tasks waiting, or a boolean |
---|
146 | indication that one or more tasks are waiting. |
---|
147 | |
---|
148 | @item semcnt |
---|
149 | is the current semaphore count. |
---|
150 | |
---|
151 | @end table |
---|
152 | |
---|
153 | The information in this table is very volatile and should be used |
---|
154 | with caution in an application. |
---|
155 | |
---|
156 | @section Operations |
---|
157 | |
---|
158 | @subsection Using as a Binary Semaphore |
---|
159 | |
---|
160 | Creating a semaphore with a limit on the count of 1 effectively |
---|
161 | restricts the semaphore to being a binary semaphore. When the |
---|
162 | binary semaphore is available, the count is 1. When the binary |
---|
163 | semaphore is unavailable, the count is 0. |
---|
164 | |
---|
165 | Since this does not result in a true binary semaphore, advanced |
---|
166 | binary features like the Priority Inheritance and Priority |
---|
167 | Ceiling Protocols are not available. |
---|
168 | |
---|
169 | @section System Calls |
---|
170 | |
---|
171 | This section details the semaphore manager's services. |
---|
172 | A subsection is dedicated to each of this manager's services |
---|
173 | and describes the calling sequence, related constants, usage, |
---|
174 | and status codes. |
---|
175 | |
---|
176 | |
---|
177 | @c |
---|
178 | @c cre_sem |
---|
179 | @c |
---|
180 | |
---|
181 | @page |
---|
182 | @subsection cre_sem - Create Semaphore |
---|
183 | |
---|
184 | @subheading CALLING SEQUENCE: |
---|
185 | |
---|
186 | @ifset is-C |
---|
187 | @example |
---|
188 | ER cre_sem( |
---|
189 | ID semid, |
---|
190 | T_CSEM *pk_csem |
---|
191 | ); |
---|
192 | @end example |
---|
193 | @end ifset |
---|
194 | |
---|
195 | @ifset is-Ada |
---|
196 | @end ifset |
---|
197 | |
---|
198 | @subheading STATUS CODES: |
---|
199 | |
---|
200 | @code{E_OK} - Normal Completion |
---|
201 | |
---|
202 | @code{E_ID} - Invalid ID number (semid was invalid or could not be used) |
---|
203 | |
---|
204 | @code{E_NOMEM} - Insufficient memory (Memory for control block cannot be |
---|
205 | allocated) |
---|
206 | |
---|
207 | @code{E_OACV} - Object access violation (A semid less than -4 was |
---|
208 | specified from a user task. This is implementation dependent.) |
---|
209 | |
---|
210 | @code{E_RSATR} - Reserved attribute (sematr was invalid or could not be |
---|
211 | used) |
---|
212 | |
---|
213 | @code{E_OBJ} - Invalid object state (a semaphore of the same ID already |
---|
214 | exists) |
---|
215 | |
---|
216 | @code{E_PAR} - Parameter error (pk_csem is invalid and/or isemcnt or |
---|
217 | maxsem is negative or invalid) |
---|
218 | |
---|
219 | @code{EN_OBJNO} - An object number which could not be accessed on the |
---|
220 | target node is specified. |
---|
221 | |
---|
222 | @code{EN_CTXID} - Specified an object on another node when the system call |
---|
223 | was issued from a task in dispatch disabled state or from a task- |
---|
224 | independent portion |
---|
225 | |
---|
226 | @code{EN_PAR} - A value outside the range supported by the target node |
---|
227 | and/or transmission packet format was specified as a parameter (a value |
---|
228 | outside supported range was specified for exinf, sematr, isemcnt and/or |
---|
229 | maxsem) |
---|
230 | |
---|
231 | @subheading DESCRIPTION: |
---|
232 | |
---|
233 | This routine creates a semaphore that resides on the local node. The |
---|
234 | semaphore is initialized based on the attributes specified in the |
---|
235 | @code{pk_csem} structure. The initial and maximum counts of the |
---|
236 | semaphore are set based on the @code{isemcnt} and @code{maxsem} fields |
---|
237 | in this structure. |
---|
238 | |
---|
239 | Specifying @code{TA_TPRI} in the @code{sematr} field of the |
---|
240 | semaphore attributes structure causes tasks |
---|
241 | waiting for a semaphore to be serviced according to task |
---|
242 | priority. When @code{TA_TFIFO} is selected, tasks are serviced in First |
---|
243 | In-First Out order. |
---|
244 | |
---|
245 | @subheading NOTES: |
---|
246 | |
---|
247 | Multiprocessing is not supported. Thus none of the "EN_" status codes |
---|
248 | will be returned. |
---|
249 | |
---|
250 | All memory is preallocated for RTEMS ITRON objects. Thus, no dynamic |
---|
251 | memory allocation is performed by @code{cre_sem} and the @code{E_NOMEM} |
---|
252 | error can not be returned. |
---|
253 | |
---|
254 | The ITRON specification calls for @code{E_OACV} to be returned for |
---|
255 | some invalid semaphore IDs. This implementation returns @code{E_ID} |
---|
256 | for all invalid IDs as there are no system reserved ITRON objects. |
---|
257 | |
---|
258 | This directive will not cause the running task to be |
---|
259 | preempted. |
---|
260 | |
---|
261 | The following semaphore attribute constants are |
---|
262 | defined by RTEMS: |
---|
263 | |
---|
264 | @itemize @bullet |
---|
265 | @item @code{TA_TFIFO} - tasks wait by FIFO |
---|
266 | |
---|
267 | @item @code{TA_TPRI} - tasks wait by priority |
---|
268 | |
---|
269 | @end itemize |
---|
270 | |
---|
271 | @c |
---|
272 | @c del_sem |
---|
273 | @c |
---|
274 | |
---|
275 | @page |
---|
276 | @subsection del_sem - Delete Semaphore |
---|
277 | |
---|
278 | @subheading CALLING SEQUENCE: |
---|
279 | |
---|
280 | @ifset is-C |
---|
281 | @example |
---|
282 | ER del_sem( |
---|
283 | ID semid |
---|
284 | ); |
---|
285 | @end example |
---|
286 | @end ifset |
---|
287 | |
---|
288 | @ifset is-Ada |
---|
289 | @end ifset |
---|
290 | |
---|
291 | @subheading STATUS CODES: |
---|
292 | |
---|
293 | @code{E_OK} - Normal Completion |
---|
294 | |
---|
295 | @code{E_ID} - Invalid ID number (semid was invalid or could not be used) |
---|
296 | |
---|
297 | @code{E_NOEXS} - Object does not exist (the semaphore specified by semid |
---|
298 | does not exist) |
---|
299 | |
---|
300 | @code{E_OACV} - Object access violation (A semid less than -4 was |
---|
301 | specified from a user task. This is implementation dependent.) |
---|
302 | |
---|
303 | @code{EN_OBJNO} - An object number which could not be accessed on the |
---|
304 | target node is specified. |
---|
305 | |
---|
306 | @code{EN_CTXID} - Specified an object on another node when the system call |
---|
307 | was issued from a task in dispatch disabled state or from a |
---|
308 | task-independent portion |
---|
309 | |
---|
310 | @subheading DESCRIPTION: |
---|
311 | |
---|
312 | This routine deletes the semaphore specified by @code{semid}. |
---|
313 | All tasks blocked waiting to acquire the semaphore will be |
---|
314 | readied and returned a status code which indicates that the |
---|
315 | semaphore was deleted. The control block for this semaphore |
---|
316 | is reclaimed by RTEMS. |
---|
317 | |
---|
318 | |
---|
319 | @subheading NOTES: |
---|
320 | |
---|
321 | Multiprocessing is not supported. Thus none of the "EN_" status codes |
---|
322 | will be returned. |
---|
323 | |
---|
324 | This implementation does not distinguish between an invalid ID (@code{E_ID}) |
---|
325 | and a valid id for a non-existent object (@code{E_NOEXS}). In addition, |
---|
326 | there are no system reserved ITRON objects so the @code{E_OACV} error |
---|
327 | is not returned. All IDs which do not correspond to an active user |
---|
328 | created semaphore return @code{E_ID}. |
---|
329 | |
---|
330 | The calling task will be preempted if it is enabled |
---|
331 | by the task's execution mode and a higher priority local task is |
---|
332 | waiting on the deleted semaphore. The calling task will NOT be |
---|
333 | preempted if all of the tasks that are waiting on the semaphore |
---|
334 | are remote tasks. |
---|
335 | |
---|
336 | The calling task does not have to be the task that |
---|
337 | created the semaphore. Any local task that knows the semaphore |
---|
338 | id can delete the semaphore. |
---|
339 | |
---|
340 | |
---|
341 | @c |
---|
342 | @c sig_sem |
---|
343 | @c |
---|
344 | |
---|
345 | @page |
---|
346 | @subsection sig_sem - Signal Semaphore |
---|
347 | |
---|
348 | @subheading CALLING SEQUENCE: |
---|
349 | |
---|
350 | @ifset is-C |
---|
351 | @example |
---|
352 | ER sig_sem( |
---|
353 | ID semid |
---|
354 | ); |
---|
355 | @end example |
---|
356 | @end ifset |
---|
357 | |
---|
358 | @ifset is-Ada |
---|
359 | @end ifset |
---|
360 | |
---|
361 | @subheading STATUS CODES: |
---|
362 | |
---|
363 | @code{E_OK} - Normal Completion |
---|
364 | |
---|
365 | @code{E_ID} - Invalid ID number (semid was invalid or could not be used) |
---|
366 | |
---|
367 | @code{E_NOEXS} - Object does not exist (the semaphore specified by semid |
---|
368 | does not exist) |
---|
369 | |
---|
370 | @code{E_OACV} - Object access violation (A semid less than -4 was |
---|
371 | specified from a user task. This is implementation dependent.) |
---|
372 | |
---|
373 | @code{E_QOVR} - Queuing or nesting overflow (the queuing count given by |
---|
374 | semcnt went over the maximum allowed) |
---|
375 | |
---|
376 | @code{EN_OBJNO} - An object number which could not be accessed on the |
---|
377 | target node is specified. |
---|
378 | |
---|
379 | @code{EN_CTXID} - Specified an object on another node when the system call |
---|
380 | was issued from a task in dispatch disabled state or from a |
---|
381 | task-independent portion |
---|
382 | |
---|
383 | @subheading DESCRIPTION: |
---|
384 | |
---|
385 | @subheading NOTES: |
---|
386 | |
---|
387 | Multiprocessing is not supported. Thus none of the "EN_" status codes |
---|
388 | will be returned. |
---|
389 | |
---|
390 | This implementation does not distinguish between an invalid ID (@code{E_ID}) |
---|
391 | and a valid id for a non-existent object (@code{E_NOEXS}). In addition, |
---|
392 | there are no system reserved ITRON objects so the @code{E_OACV} error |
---|
393 | is not returned. All IDs which do not correspond to an active user |
---|
394 | created semaphore return @code{E_ID}. |
---|
395 | |
---|
396 | @c |
---|
397 | @c wai_sem |
---|
398 | @c |
---|
399 | |
---|
400 | @page |
---|
401 | @subsection wai_sem - Wait on Semaphore |
---|
402 | |
---|
403 | @subheading CALLING SEQUENCE: |
---|
404 | |
---|
405 | @ifset is-C |
---|
406 | @example |
---|
407 | ER wai_sem( |
---|
408 | ID semid |
---|
409 | ); |
---|
410 | @end example |
---|
411 | @end ifset |
---|
412 | |
---|
413 | @ifset is-Ada |
---|
414 | @end ifset |
---|
415 | |
---|
416 | @subheading STATUS CODES: |
---|
417 | |
---|
418 | @code{E_OK} - Normal Completion |
---|
419 | |
---|
420 | @code{E_ID} - Invalid ID number (semid was invalid or could not be used) |
---|
421 | |
---|
422 | @code{E_NOEXS} - Object does not exist (the semaphore specified by semid |
---|
423 | does not exist) |
---|
424 | |
---|
425 | @code{E_OACV} - Object access violation (A semid less than -4 was |
---|
426 | specified from a user task. This is implementation dependent.) |
---|
427 | |
---|
428 | @code{E_DLT} - The object being waited for was deleted (the specified |
---|
429 | semaphore was deleted while waiting) |
---|
430 | |
---|
431 | @code{E_RLWAI} - Wait state was forcibly released (rel_wai was received |
---|
432 | while waiting) |
---|
433 | |
---|
434 | @code{E_CTX} - Context error (issued from task-independent portions or a |
---|
435 | task in dispatch disabled state) |
---|
436 | |
---|
437 | @code{EN_OBJNO} - An object number which could not be accessed on the |
---|
438 | target node is specified. |
---|
439 | |
---|
440 | @code{EN_PAR} - A value outside the range supported by the target node |
---|
441 | and/or transmission packet format was specified as a parameter (a value |
---|
442 | outside supported range was specified for tmout) |
---|
443 | |
---|
444 | @subheading DESCRIPTION: |
---|
445 | |
---|
446 | This routine attempts to acquire the semaphore specified by @code{semid}. |
---|
447 | If the semaphore is available (i.e. positive semaphore count), then the |
---|
448 | semaphore count is decremented and the calling task returns immediately. |
---|
449 | Otherwise the calling tasking is blocked until the semaphore is released |
---|
450 | by a subsequent invocation of @code{sig_sem}. |
---|
451 | |
---|
452 | @subheading NOTES: |
---|
453 | |
---|
454 | Multiprocessing is not supported. Thus none of the "EN_" status codes |
---|
455 | will be returned. |
---|
456 | |
---|
457 | This implementation does not distinguish between an invalid ID (@code{E_ID}) |
---|
458 | and a valid id for a non-existent object (@code{E_NOEXS}). In addition, |
---|
459 | there are no system reserved ITRON objects so the @code{E_OACV} error |
---|
460 | is not returned. All IDs which do not correspond to an active user |
---|
461 | created semaphore return @code{E_ID}. |
---|
462 | |
---|
463 | If the semaphore is not available, then the calling task will be blocked. |
---|
464 | |
---|
465 | @c |
---|
466 | @c preq_sem |
---|
467 | @c |
---|
468 | |
---|
469 | @page |
---|
470 | @subsection preq_sem - Poll and Request Semaphore |
---|
471 | |
---|
472 | @subheading CALLING SEQUENCE: |
---|
473 | |
---|
474 | @ifset is-C |
---|
475 | @example |
---|
476 | ER preq_sem( |
---|
477 | ID semid |
---|
478 | ); |
---|
479 | @end example |
---|
480 | @end ifset |
---|
481 | |
---|
482 | @ifset is-Ada |
---|
483 | @end ifset |
---|
484 | |
---|
485 | @subheading STATUS CODES: |
---|
486 | |
---|
487 | @code{E_OK} - Normal Completion |
---|
488 | |
---|
489 | @code{E_ID} - Invalid ID number (semid was invalid or could not be used) |
---|
490 | |
---|
491 | @code{E_NOEXS} - Object does not exist (the semaphore specified by semid |
---|
492 | does not exist) |
---|
493 | |
---|
494 | @code{E_OACV} - Object access violation (A semid less than -4 was |
---|
495 | specified from a user task. This is implementation dependent.) |
---|
496 | |
---|
497 | @code{E_TMOUT} - Polling failure or timeout exceeded |
---|
498 | |
---|
499 | @code{E_CTX} - Context error (issued from task-independent portions or a |
---|
500 | task in dispatch disabled state) |
---|
501 | |
---|
502 | @code{EN_OBJNO} - An object number which could not be accessed on the |
---|
503 | target node is specified. |
---|
504 | |
---|
505 | @code{EN_PAR} - A value outside the range supported by the target node |
---|
506 | and/or transmission packet format was specified as a parameter (a value |
---|
507 | outside supported range was specified for tmout) |
---|
508 | |
---|
509 | @subheading DESCRIPTION: |
---|
510 | |
---|
511 | This routine attempts to acquire the semaphore specified by @code{semid}. |
---|
512 | If the semaphore is available (i.e. positive semaphore count), then the |
---|
513 | semaphore count is decremented and the calling task returns immediately. |
---|
514 | Otherwise, the @code{E_TMOUT} error is returned to the calling task to |
---|
515 | indicate the semaphore is unavailable. |
---|
516 | |
---|
517 | @subheading NOTES: |
---|
518 | |
---|
519 | Multiprocessing is not supported. Thus none of the "EN_" status codes |
---|
520 | will be returned. |
---|
521 | |
---|
522 | This implementation does not distinguish between an invalid ID (@code{E_ID}) |
---|
523 | and a valid id for a non-existent object (@code{E_NOEXS}). In addition, |
---|
524 | there are no system reserved ITRON objects so the @code{E_OACV} error |
---|
525 | is not returned. All IDs which do not correspond to an active user |
---|
526 | created semaphore return @code{E_ID}. |
---|
527 | |
---|
528 | This routine will not cause the running task to be preempted. |
---|
529 | |
---|
530 | @c |
---|
531 | @c twai_sem |
---|
532 | @c |
---|
533 | |
---|
534 | @page |
---|
535 | @subsection twai_sem - Wait on Semaphore with Timeout |
---|
536 | |
---|
537 | @subheading CALLING SEQUENCE: |
---|
538 | |
---|
539 | @ifset is-C |
---|
540 | @example |
---|
541 | ER twai_sem( |
---|
542 | ID semid, |
---|
543 | TMO tmout |
---|
544 | ); |
---|
545 | @end example |
---|
546 | @end ifset |
---|
547 | |
---|
548 | @ifset is-Ada |
---|
549 | @end ifset |
---|
550 | |
---|
551 | @subheading STATUS CODES: |
---|
552 | |
---|
553 | @code{E_OK} - Normal Completion |
---|
554 | |
---|
555 | @code{E_ID} - Invalid ID number (semid was invalid or could not be used) |
---|
556 | |
---|
557 | @code{E_NOEXS} - Object does not exist (the semaphore specified by semid |
---|
558 | does not exist) |
---|
559 | |
---|
560 | @code{E_OACV} - Object access violation (A semid less than -4 was |
---|
561 | specified from a user task. This is implementation dependent.) |
---|
562 | |
---|
563 | @code{E_PAR} - Parameter error (tmout is -2 or less) |
---|
564 | |
---|
565 | @code{E_DLT} - The object being waited for was deleted (the specified |
---|
566 | semaphore was deleted while waiting) |
---|
567 | |
---|
568 | @code{E_RLWAI} - Wait state was forcibly released (rel_wai was received |
---|
569 | while waiting) |
---|
570 | |
---|
571 | @code{E_TMOUT} - Polling failure or timeout exceeded |
---|
572 | |
---|
573 | @code{E_CTX} - Context error (issued from task-independent portions or a |
---|
574 | task in dispatch disabled state) |
---|
575 | |
---|
576 | @code{EN_OBJNO} - An object number which could not be accessed on the |
---|
577 | target node is specified. |
---|
578 | |
---|
579 | @code{EN_PAR} - A value outside the range supported by the target node |
---|
580 | and/or transmission packet format was specified as a parameter (a value |
---|
581 | outside supported range was specified for tmout) |
---|
582 | |
---|
583 | @subheading DESCRIPTION: |
---|
584 | |
---|
585 | This routine attempts to acquire the semaphore specified by @code{semid}. |
---|
586 | If the semaphore is available (i.e. positive semaphore count), then the |
---|
587 | semaphore count is decremented and the calling task returns immediately. |
---|
588 | Otherwise the calling tasking is blocked until the semaphore is released |
---|
589 | by a subsequent invocation of @code{sig_sem} or the timeout period specified |
---|
590 | by @code{tmout} milliseconds is exceeded. If the timeout period is exceeded, |
---|
591 | then the @code{E_TMOUT} error is returned. |
---|
592 | |
---|
593 | By specifiying @code{tmout} as @code{TMO_FEVR}, this routine has the same |
---|
594 | behavior as @code{wai_sem}. Similarly, by specifiying @code{tmout} as |
---|
595 | @code{TMO_POL}, this routine has the same behavior as @code{preq_sem}. |
---|
596 | |
---|
597 | @subheading NOTES: |
---|
598 | |
---|
599 | Multiprocessing is not supported. Thus none of the "EN_" status codes |
---|
600 | will be returned. |
---|
601 | |
---|
602 | This implementation does not distinguish between an invalid ID (@code{E_ID}) |
---|
603 | and a valid id for a non-existent object (@code{E_NOEXS}). In addition, |
---|
604 | there are no system reserved ITRON objects so the @code{E_OACV} error |
---|
605 | is not returned. All IDs which do not correspond to an active user |
---|
606 | created semaphore return @code{E_ID}. |
---|
607 | |
---|
608 | This routine may cause the calling task to block. |
---|
609 | |
---|
610 | A clock tick is required to support the timeout functionality of |
---|
611 | this routine. |
---|
612 | |
---|
613 | @c |
---|
614 | @c ref_sem |
---|
615 | @c |
---|
616 | |
---|
617 | @page |
---|
618 | @subsection ref_sem - Reference Semaphore Status |
---|
619 | |
---|
620 | @subheading CALLING SEQUENCE: |
---|
621 | |
---|
622 | @ifset is-C |
---|
623 | @example |
---|
624 | ER ref_sem( |
---|
625 | T_RSEM *pk_rsem, |
---|
626 | ID semid |
---|
627 | ); |
---|
628 | @end example |
---|
629 | @end ifset |
---|
630 | |
---|
631 | @ifset is-Ada |
---|
632 | @end ifset |
---|
633 | |
---|
634 | @subheading STATUS CODES: |
---|
635 | |
---|
636 | @code{E_OK} - Normal Completion |
---|
637 | |
---|
638 | @code{E_ID} - Invalid ID number (semid was invalid or could not be used) |
---|
639 | |
---|
640 | @code{E_NOEXS} - Object does not exist (the semaphore specified by semid |
---|
641 | does not exist) |
---|
642 | |
---|
643 | @code{E_OACV} - Object access violation (A semid less than -4 was |
---|
644 | specified from a user task. This is implementation dependent.) |
---|
645 | |
---|
646 | @code{E_PAR} - Parameter error (the packet address for the return |
---|
647 | parameters could not be used) |
---|
648 | |
---|
649 | @code{EN_OBJNO} - An object number which could not be accessed on the |
---|
650 | target node is specified. |
---|
651 | |
---|
652 | @code{EN_CTXID} - Specified an object on another node when the system call |
---|
653 | was issued from a task in dispatch disabled state or from a |
---|
654 | task-independent portion |
---|
655 | |
---|
656 | @code{EN_RPAR} - A value outside the range supported by the requesting |
---|
657 | node and/or transmission packet format was returned as a parameter (a |
---|
658 | value outside supported range was specified for exinf, wtsk or semcnt) |
---|
659 | |
---|
660 | @subheading DESCRIPTION: |
---|
661 | |
---|
662 | This routine returns status information on the semaphore specified |
---|
663 | by @code{semid}. The @code{pk_rsem} structure is filled in by |
---|
664 | this service call. |
---|
665 | |
---|
666 | @subheading NOTES: |
---|
667 | |
---|
668 | Multiprocessing is not supported. Thus none of the "EN_" status codes |
---|
669 | will be returned. |
---|
670 | |
---|
671 | This implementation does not distinguish between an invalid ID (@code{E_ID}) |
---|
672 | and a valid id for a non-existent object (@code{E_NOEXS}). In addition, |
---|
673 | there are no system reserved ITRON objects so the @code{E_OACV} error |
---|
674 | is not returned. All IDs which do not correspond to an active user |
---|
675 | created semaphore return @code{E_ID}. |
---|
676 | |
---|
677 | This routine will not cause the running task to be preempted. |
---|
678 | |
---|