source: rtems/cpukit/rtems/src/semflush.c @ dce48791

5
Last change on this file since dce48791 was dce48791, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 11:37:59

score: Add Status_Control for all APIs

Unify the status codes of the Classic and POSIX API to use the new enum
Status_Control. This eliminates the Thread_Control::Wait::timeout_code
field and the timeout parameter of _Thread_queue_Enqueue_critical() and
_MPCI_Send_request_packet(). It gets rid of the status code translation
tables and instead uses simple bit operations to get the status for a
particular API. This enables translation of status code constants at
compile time. Add _Thread_Wait_get_status() to avoid direct access of
thread internal data structures.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Semaphore Flush
5 *  @ingroup ClassicSem
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/semimpl.h>
22#include <rtems/rtems/attrimpl.h>
23
24rtems_status_code rtems_semaphore_flush( rtems_id id )
25{
26  Semaphore_Control    *the_semaphore;
27  Thread_queue_Context  queue_context;
28  rtems_attribute       attribute_set;
29
30  the_semaphore = _Semaphore_Get(
31    id,
32    &queue_context,
33    _Semaphore_MP_Send_object_was_deleted
34  );
35
36  if ( the_semaphore == NULL ) {
37#if defined(RTEMS_MULTIPROCESSING)
38    if ( _Semaphore_MP_Is_remote( id ) ) {
39      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
40    }
41#endif
42
43    return RTEMS_INVALID_ID;
44  }
45
46  attribute_set = the_semaphore->attribute_set;
47
48#if defined(RTEMS_SMP)
49  if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
50    _ISR_lock_ISR_enable( &queue_context.Lock_context );
51    return RTEMS_NOT_DEFINED;
52  } else
53#endif
54  if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
55    _CORE_mutex_Acquire_critical(
56      &the_semaphore->Core_control.mutex,
57      &queue_context
58    );
59    _CORE_mutex_Flush(
60      &the_semaphore->Core_control.mutex,
61      _Thread_queue_Flush_status_unavailable,
62      &queue_context
63    );
64  } else {
65    _CORE_semaphore_Acquire_critical(
66      &the_semaphore->Core_control.semaphore,
67      &queue_context
68    );
69    _CORE_semaphore_Flush(
70      &the_semaphore->Core_control.semaphore,
71      &queue_context
72    );
73  }
74  return RTEMS_SUCCESSFUL;
75}
Note: See TracBrowser for help on using the repository browser.