source: rtems/cpukit/rtems/src/semrelease.c @ 33e250c9

5
Last change on this file since 33e250c9 was 33e250c9, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 13:41:41

score: Rework CORE priority ceiling mutex

Rework seize and surrender methods to use CORE_ceiling_mutex_Control.
This eliminates CORE_mutex_Disciplines.

  • 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/rtems/semimpl.h>
25#include <rtems/rtems/statusimpl.h>
26
27rtems_status_code rtems_semaphore_release( rtems_id id )
28{
29  Semaphore_Control    *the_semaphore;
30  Thread_queue_Context  queue_context;
31  Thread_Control       *executing;
32  Status_Control        status;
33
34  the_semaphore = _Semaphore_Get( id, &queue_context );
35
36  if ( the_semaphore == NULL ) {
37#if defined(RTEMS_MULTIPROCESSING)
38    return _Semaphore_MP_Release( id );
39#else
40    return RTEMS_INVALID_ID;
41#endif
42  }
43
44  executing = _Thread_Executing;
45
46  _Thread_queue_Context_set_MP_callout(
47    &queue_context,
48    _Semaphore_Core_mutex_mp_support
49  );
50
51  switch ( the_semaphore->variant ) {
52#if defined(RTEMS_SMP)
53    case SEMAPHORE_VARIANT_MRSP:
54      status = _MRSP_Surrender(
55        &the_semaphore->Core_control.mrsp,
56        executing,
57        &queue_context
58      );
59      break;
60#endif
61    case SEMAPHORE_VARIANT_MUTEX:
62      status = _CORE_mutex_Surrender(
63        &the_semaphore->Core_control.Mutex.Recursive.Mutex,
64        &queue_context
65      );
66      break;
67    case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
68      status = _CORE_ceiling_mutex_Surrender(
69        &the_semaphore->Core_control.Mutex,
70        executing,
71        &queue_context
72      );
73      break;
74    case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
75      _CORE_recursive_mutex_Surrender_no_protocol_classic(
76        &the_semaphore->Core_control.Mutex.Recursive,
77        _Semaphore_Get_operations( the_semaphore ),
78        &queue_context
79      );
80      status = STATUS_SUCCESSFUL;
81      break;
82    case SEMAPHORE_VARIANT_SIMPLE_BINARY:
83      status = _CORE_semaphore_Surrender(
84        &the_semaphore->Core_control.semaphore,
85        _Semaphore_Get_operations( the_semaphore ),
86        1,
87        &queue_context
88      );
89      _Assert(
90        status == STATUS_SUCCESSFUL
91          || status == STATUS_MAXIMUM_COUNT_EXCEEDED
92      );
93      status = STATUS_SUCCESSFUL;
94      break;
95    default:
96      _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
97      status = _CORE_semaphore_Surrender(
98        &the_semaphore->Core_control.semaphore,
99        _Semaphore_Get_operations( the_semaphore ),
100        UINT32_MAX,
101        &queue_context
102      );
103      break;
104  }
105
106  return _Status_Get( status );
107}
Note: See TracBrowser for help on using the repository browser.