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

Last change on this file since 3692095 was 3692095, checked in by Sebastian Huber <sebastian.huber@…>, on May 30, 2016 at 8:41:22 AM

rtems: Move MrsP semaphore operations

Move MrsP semaphore operations to a less prominent location. Fix field
name.

  • 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    case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
53      status = _CORE_recursive_mutex_Surrender(
54        &the_semaphore->Core_control.Mutex.Recursive,
55        executing,
56        &queue_context
57      );
58      break;
59    case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
60      status = _CORE_ceiling_mutex_Surrender(
61        &the_semaphore->Core_control.Mutex,
62        executing,
63        &queue_context
64      );
65      break;
66    case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
67      _CORE_recursive_mutex_Surrender_no_protocol_classic(
68        &the_semaphore->Core_control.Mutex.Recursive,
69        _Semaphore_Get_operations( the_semaphore ),
70        &queue_context
71      );
72      status = STATUS_SUCCESSFUL;
73      break;
74    case SEMAPHORE_VARIANT_SIMPLE_BINARY:
75      status = _CORE_semaphore_Surrender(
76        &the_semaphore->Core_control.semaphore,
77        _Semaphore_Get_operations( the_semaphore ),
78        1,
79        &queue_context
80      );
81      _Assert(
82        status == STATUS_SUCCESSFUL
83          || status == STATUS_MAXIMUM_COUNT_EXCEEDED
84      );
85      status = STATUS_SUCCESSFUL;
86      break;
87#if defined(RTEMS_SMP)
88    case SEMAPHORE_VARIANT_MRSP:
89      status = _MRSP_Surrender(
90        &the_semaphore->Core_control.MRSP,
91        executing,
92        &queue_context
93      );
94      break;
95#endif
96    default:
97      _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
98      status = _CORE_semaphore_Surrender(
99        &the_semaphore->Core_control.semaphore,
100        _Semaphore_Get_operations( the_semaphore ),
101        UINT32_MAX,
102        &queue_context
103      );
104      break;
105  }
106
107  return _Status_Get( status );
108}
Note: See TracBrowser for help on using the repository browser.