[e7264f07] | 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 | |
---|
| 62 | the_semaphore = _Semaphore_Get( id, &location ); |
---|
| 63 | switch ( location ) { |
---|
| 64 | |
---|
| 65 | case OBJECTS_REMOTE: |
---|
| 66 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 67 | _Thread_Dispatch(); |
---|
| 68 | return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; |
---|
| 69 | #endif |
---|
| 70 | |
---|
| 71 | case OBJECTS_ERROR: |
---|
| 72 | return RTEMS_INVALID_ID; |
---|
| 73 | |
---|
| 74 | case OBJECTS_LOCAL: |
---|
| 75 | if ( _Attributes_Is_binary_semaphore(the_semaphore->attribute_set) ) { |
---|
| 76 | _CORE_mutex_Flush( |
---|
| 77 | &the_semaphore->Core_control.mutex, |
---|
| 78 | NULL, |
---|
| 79 | CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT |
---|
| 80 | ); |
---|
| 81 | } else { |
---|
| 82 | _CORE_semaphore_Flush( |
---|
| 83 | &the_semaphore->Core_control.semaphore, |
---|
| 84 | NULL, |
---|
| 85 | CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT |
---|
| 86 | ); |
---|
| 87 | } |
---|
| 88 | return RTEMS_SUCCESSFUL; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
---|
| 92 | } |
---|