source: rtems/cpukit/rtems/src/semrelease.c @ bdf23b6c

4.115
Last change on this file since bdf23b6c was bdf23b6c, checked in by Joel Sherrill <joel.sherrill@…>, on 03/10/15 at 17:39:59

cpukit: Remove old DESCRIPTION: in comments

These were remnants of pre-Doxygen comment style.

  • Property mode set to 100644
File size: 3.0 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
35#include <rtems/score/interr.h>
36
37/*
38 *  rtems_semaphore_release
39 *
40 *  This directive allows a thread to release a semaphore.
41 *
42 *  Input parameters:
43 *    id - semaphore id
44 *
45 *  Output parameters:
46 *    RTEMS_SUCCESSFUL - if successful
47 *    error code        - if unsuccessful
48 */
49
50#if defined(RTEMS_MULTIPROCESSING)
51#define MUTEX_MP_SUPPORT _Semaphore_Core_mutex_mp_support
52#else
53#define MUTEX_MP_SUPPORT NULL
54#endif
55
56rtems_status_code rtems_semaphore_release(
57  rtems_id   id
58)
59{
60  Semaphore_Control          *the_semaphore;
61  Objects_Locations           location;
62  CORE_mutex_Status           mutex_status;
63  CORE_semaphore_Status       semaphore_status;
64  rtems_attribute             attribute_set;
65
66  the_semaphore = _Semaphore_Get( id, &location );
67  switch ( location ) {
68
69    case OBJECTS_LOCAL:
70      attribute_set = the_semaphore->attribute_set;
71#if defined(RTEMS_SMP)
72      if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
73        MRSP_Status mrsp_status = _MRSP_Release(
74          &the_semaphore->Core_control.mrsp,
75          _Thread_Get_executing()
76        );
77        _Objects_Put( &the_semaphore->Object );
78        return _Semaphore_Translate_MRSP_status_code( mrsp_status );
79      } else
80#endif
81      if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
82        mutex_status = _CORE_mutex_Surrender(
83          &the_semaphore->Core_control.mutex,
84          id,
85          MUTEX_MP_SUPPORT
86        );
87        _Objects_Put( &the_semaphore->Object );
88        return _Semaphore_Translate_core_mutex_return_code( mutex_status );
89      } else {
90        semaphore_status = _CORE_semaphore_Surrender(
91          &the_semaphore->Core_control.semaphore,
92          id,
93          MUTEX_MP_SUPPORT
94        );
95        _Objects_Put( &the_semaphore->Object );
96        return
97          _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
98      }
99
100#if defined(RTEMS_MULTIPROCESSING)
101    case OBJECTS_REMOTE:
102      return _Semaphore_MP_Send_request_packet(
103        SEMAPHORE_MP_RELEASE_REQUEST,
104        id,
105        0,                               /* Not used */
106        MPCI_DEFAULT_TIMEOUT
107      );
108#endif
109
110    case OBJECTS_ERROR:
111      break;
112  }
113
114  return RTEMS_INVALID_ID;
115}
Note: See TracBrowser for help on using the repository browser.