source: rtems/cpukit/rtems/src/semrelease.c @ 242a05a

5
Last change on this file since 242a05a was 242a05a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/16 at 13:04:34

score: Rename _MRSP_Obtain()

Rename _MRSP_Obtain() into _MRSP_Seize(). Rename _MRSP_Release() into
_MRSP_Surrender(). This avoids confusion with the ISR lock acquire and
release.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS Semaphore Release
5 * @ingroup ClassicSem Semaphores
6 *
7 * This file contains the implementation of the Classic API directive
8 * rtems_semaphore_release().
9 */
10
11/*
12 *  COPYRIGHT (c) 1989-2014.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems/system.h>
25#include <rtems/rtems/status.h>
26#include <rtems/rtems/support.h>
27#include <rtems/rtems/attrimpl.h>
28#include <rtems/score/isr.h>
29#include <rtems/rtems/options.h>
30#include <rtems/rtems/semimpl.h>
31#include <rtems/score/coremuteximpl.h>
32#include <rtems/score/coresemimpl.h>
33#include <rtems/score/thread.h>
34#include <rtems/score/interr.h>
35
36rtems_status_code rtems_semaphore_release(
37  rtems_id   id
38)
39{
40  Semaphore_Control          *the_semaphore;
41  Objects_Locations           location;
42  CORE_mutex_Status           mutex_status;
43  CORE_semaphore_Status       semaphore_status;
44  rtems_attribute             attribute_set;
45  ISR_lock_Context            lock_context;
46
47  the_semaphore = _Semaphore_Get_interrupt_disable(
48    id,
49    &location,
50    &lock_context
51  );
52  switch ( location ) {
53
54    case OBJECTS_LOCAL:
55      attribute_set = the_semaphore->attribute_set;
56#if defined(RTEMS_SMP)
57      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
58        MRSP_Status mrsp_status;
59
60        mrsp_status = _MRSP_Surrender(
61          &the_semaphore->Core_control.mrsp,
62          _Thread_Executing,
63          &lock_context
64        );
65        return _Semaphore_Translate_MRSP_status_code( mrsp_status );
66      } else
67#endif
68      if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
69        mutex_status = _CORE_mutex_Surrender(
70          &the_semaphore->Core_control.mutex,
71          _Semaphore_Core_mutex_mp_support,
72          id,
73          &lock_context
74        );
75        return _Semaphore_Translate_core_mutex_return_code( mutex_status );
76      } else {
77        semaphore_status = _CORE_semaphore_Surrender(
78          &the_semaphore->Core_control.semaphore,
79          _Semaphore_Core_mutex_mp_support,
80          id,
81          &lock_context
82        );
83        return
84          _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
85      }
86
87#if defined(RTEMS_MULTIPROCESSING)
88    case OBJECTS_REMOTE:
89      return _Semaphore_MP_Send_request_packet(
90        SEMAPHORE_MP_RELEASE_REQUEST,
91        id,
92        0,                               /* Not used */
93        MPCI_DEFAULT_TIMEOUT
94      );
95#endif
96
97    case OBJECTS_ERROR:
98      break;
99  }
100
101  return RTEMS_INVALID_ID;
102}
Note: See TracBrowser for help on using the repository browser.