4.104.114.84.95
Line | |
---|
1 | /* |
---|
2 | * COPYRIGHT (c) 1989-1999. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <rtems/itron.h> |
---|
17 | |
---|
18 | #include <rtems/itron/semaphore.h> |
---|
19 | #include <rtems/itron/task.h> |
---|
20 | #include <rtems/score/tod.h> |
---|
21 | |
---|
22 | /* |
---|
23 | * ref_sem - Reference Semaphore Status |
---|
24 | * |
---|
25 | * This function implements the ITRON 3.0 ref_sem() service. |
---|
26 | */ |
---|
27 | |
---|
28 | ER ref_sem( |
---|
29 | ID semid, |
---|
30 | T_RSEM *pk_rsem |
---|
31 | ) |
---|
32 | { |
---|
33 | ITRON_Semaphore_Control *the_semaphore; |
---|
34 | Objects_Locations location; |
---|
35 | |
---|
36 | if ( !pk_rsem ) |
---|
37 | return E_PAR; /* XXX check this error code */ |
---|
38 | |
---|
39 | the_semaphore = _ITRON_Semaphore_Get( semid, &location ); |
---|
40 | switch ( location ) { |
---|
41 | case OBJECTS_REMOTE: /* Multiprocessing not supported */ |
---|
42 | case OBJECTS_ERROR: |
---|
43 | return _ITRON_Semaphore_Clarify_get_id_error( semid ); |
---|
44 | |
---|
45 | case OBJECTS_LOCAL: |
---|
46 | /* |
---|
47 | * Fill in the current semaphore count |
---|
48 | */ |
---|
49 | |
---|
50 | pk_rsem->semcnt = _CORE_semaphore_Get_count( &the_semaphore->semaphore ); |
---|
51 | |
---|
52 | /* |
---|
53 | * Fill in whether or not there is a waiting task |
---|
54 | */ |
---|
55 | |
---|
56 | if ( !_Thread_queue_First( &the_semaphore->semaphore.Wait_queue ) ) |
---|
57 | pk_rsem->wtsk = FALSE; |
---|
58 | else |
---|
59 | pk_rsem->wtsk = TRUE; |
---|
60 | |
---|
61 | _Thread_Enable_dispatch(); |
---|
62 | return E_OK; |
---|
63 | } |
---|
64 | return E_OK; |
---|
65 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.