1 | /* |
---|
2 | * rtems_semaphore_flush |
---|
3 | * |
---|
4 | * DESCRIPTION: |
---|
5 | * |
---|
6 | * This package is the implementation of the flush directive |
---|
7 | * of the Semaphore Manager. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-1998. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * Copyright assigned to U.S. Government, 1994. |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.OARcorp.com/rtems/license.html. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #include <rtems/system.h> |
---|
21 | #include <rtems/rtems/status.h> |
---|
22 | #include <rtems/rtems/support.h> |
---|
23 | #include <rtems/rtems/attr.h> |
---|
24 | #include <rtems/score/isr.h> |
---|
25 | #include <rtems/score/object.h> |
---|
26 | #include <rtems/rtems/options.h> |
---|
27 | #include <rtems/rtems/sem.h> |
---|
28 | #include <rtems/score/coremutex.h> |
---|
29 | #include <rtems/score/coresem.h> |
---|
30 | #include <rtems/score/states.h> |
---|
31 | #include <rtems/score/thread.h> |
---|
32 | #include <rtems/score/threadq.h> |
---|
33 | #if defined(RTEMS_MULTIPROCESSING) |
---|
34 | #include <rtems/score/mpci.h> |
---|
35 | #endif |
---|
36 | #include <rtems/score/sysstate.h> |
---|
37 | |
---|
38 | #include <rtems/score/interr.h> |
---|
39 | |
---|
40 | /*PAGE |
---|
41 | * |
---|
42 | * rtems_semaphore_flush |
---|
43 | * |
---|
44 | * This directive allows a thread to flush the threads |
---|
45 | * pending on the semaphore. |
---|
46 | * |
---|
47 | * Input parameters: |
---|
48 | * id - semaphore id |
---|
49 | * |
---|
50 | * Output parameters: |
---|
51 | * RTEMS_SUCCESSFUL - if successful |
---|
52 | * error code - if unsuccessful |
---|
53 | */ |
---|
54 | |
---|
55 | rtems_status_code rtems_semaphore_flush( |
---|
56 | Objects_Id id |
---|
57 | ) |
---|
58 | { |
---|
59 | register Semaphore_Control *the_semaphore; |
---|
60 | Objects_Locations location; |
---|
61 | boolean wait; |
---|
62 | |
---|
63 | the_semaphore = _Semaphore_Get( id, &location ); |
---|
64 | switch ( location ) { |
---|
65 | |
---|
66 | case OBJECTS_REMOTE: |
---|
67 | #if defined(RTEMS_MULTIPROCESSING) |
---|
68 | _Thread_Dispatch(); |
---|
69 | return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; |
---|
70 | #endif |
---|
71 | |
---|
72 | case OBJECTS_ERROR: |
---|
73 | return RTEMS_INVALID_ID; |
---|
74 | |
---|
75 | case OBJECTS_LOCAL: |
---|
76 | if ( _Attributes_Is_binary_semaphore(the_semaphore->attribute_set) ) { |
---|
77 | _CORE_mutex_Flush( |
---|
78 | &the_semaphore->Core_control.mutex, |
---|
79 | NULL, |
---|
80 | CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT |
---|
81 | ); |
---|
82 | } else { |
---|
83 | _CORE_semaphore_Flush( |
---|
84 | &the_semaphore->Core_control.semaphore, |
---|
85 | NULL, |
---|
86 | CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT |
---|
87 | ); |
---|
88 | } |
---|
89 | return RTEMS_SUCCESSFUL; |
---|
90 | } |
---|
91 | |
---|
92 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
---|
93 | } |
---|