source: rtems/cpukit/rtems/src/semflush.c @ 62c528e6

5
Last change on this file since 62c528e6 was 62c528e6, checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 12:59:30

rtems: _Semaphore_Get_interrupt_disable()

Use _Objects_Get_local() for _Semaphore_Get_interrupt_disable() to get
rid of the location parameter. Move remote object handling to semaphore
MPCI support.

  • 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  ISR_lock_Context   lock_context;
28  rtems_attribute    attribute_set;
29
30  the_semaphore = _Semaphore_Get_interrupt_disable( id, &lock_context );
31
32  if ( the_semaphore == NULL ) {
33#if defined(RTEMS_MULTIPROCESSING)
34    if ( _Semaphore_MP_Is_remote( id ) ) {
35      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
36    }
37#endif
38
39    return RTEMS_INVALID_ID;
40  }
41
42  attribute_set = the_semaphore->attribute_set;
43
44#if defined(RTEMS_SMP)
45  if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
46    _ISR_lock_ISR_enable( &lock_context );
47    return RTEMS_NOT_DEFINED;
48  } else
49#endif
50  if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
51    _CORE_mutex_Acquire_critical(
52      &the_semaphore->Core_control.mutex,
53      &lock_context
54    );
55    _CORE_mutex_Flush(
56      &the_semaphore->Core_control.mutex,
57      _CORE_mutex_Unsatisfied_nowait,
58      _Semaphore_MP_Send_object_was_deleted,
59      id,
60      &lock_context
61    );
62  } else {
63    _CORE_semaphore_Acquire_critical(
64      &the_semaphore->Core_control.semaphore,
65      &lock_context
66    );
67    _CORE_semaphore_Flush(
68      &the_semaphore->Core_control.semaphore,
69      _Semaphore_MP_Send_object_was_deleted,
70      id,
71      &lock_context
72    );
73  }
74  return RTEMS_SUCCESSFUL;
75}
Note: See TracBrowser for help on using the repository browser.