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

5
Last change on this file since c3d8d9e was c3d8d9e, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 04:55:49

score: Get rid of mp_id parameter

Get rid of the mp_id parameter used for some thread queue methods. Use
THREAD_QUEUE_QUEUE_TO_OBJECT() instead.

  • Property mode set to 100644
File size: 1.9 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/rtems/semimpl.h>
25#include <rtems/rtems/attrimpl.h>
26
27rtems_status_code rtems_semaphore_release( rtems_id id )
28{
29  Semaphore_Control     *the_semaphore;
30  CORE_mutex_Status      mutex_status;
31  CORE_semaphore_Status  semaphore_status;
32  rtems_attribute        attribute_set;
33  ISR_lock_Context       lock_context;
34
35  the_semaphore = _Semaphore_Get( id, &lock_context );
36
37  if ( the_semaphore == NULL ) {
38#if defined(RTEMS_MULTIPROCESSING)
39    return _Semaphore_MP_Release( id );
40#else
41    return RTEMS_INVALID_ID;
42#endif
43  }
44
45  attribute_set = the_semaphore->attribute_set;
46#if defined(RTEMS_SMP)
47  if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
48    MRSP_Status mrsp_status;
49
50    mrsp_status = _MRSP_Surrender(
51      &the_semaphore->Core_control.mrsp,
52      _Thread_Executing,
53      &lock_context
54    );
55    return _Semaphore_Translate_MRSP_status_code( mrsp_status );
56  } else
57#endif
58  if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
59    mutex_status = _CORE_mutex_Surrender(
60      &the_semaphore->Core_control.mutex,
61      _Semaphore_Core_mutex_mp_support,
62      &lock_context
63    );
64    return _Semaphore_Translate_core_mutex_return_code( mutex_status );
65  } else {
66    semaphore_status = _CORE_semaphore_Surrender(
67      &the_semaphore->Core_control.semaphore,
68      _Semaphore_Core_mutex_mp_support,
69      &lock_context
70    );
71    return _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
72  }
73}
Note: See TracBrowser for help on using the repository browser.