source: rtems/cpukit/rtems/src/semrelease.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  Semaphore Manager
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is the implementation of the Semaphore Manager.
7 *  This manager utilizes standard Dijkstra counting semaphores to provide
8 *  synchronization and mutual exclusion capabilities.
9 *
10 *  Directives provided are:
11 *
12 *     + create a semaphore
13 *     + get an ID of a semaphore
14 *     + delete a semaphore
15 *     + acquire a semaphore
16 *     + release a semaphore
17 *
18 *  COPYRIGHT (c) 1989-2007.
19 *  On-Line Applications Research Corporation (OAR).
20 *
21 *  The license and distribution terms for this file may be
22 *  found in the file LICENSE in this distribution or at
23 *  http://www.rtems.com/license/LICENSE.
24 */
25
26#if HAVE_CONFIG_H
27#include "config.h"
28#endif
29
30#include <rtems/system.h>
31#include <rtems/rtems/status.h>
32#include <rtems/rtems/support.h>
33#include <rtems/rtems/attr.h>
34#include <rtems/score/isr.h>
35#include <rtems/score/object.h>
36#include <rtems/rtems/options.h>
37#include <rtems/rtems/sem.h>
38#include <rtems/score/coremutex.h>
39#include <rtems/score/coresem.h>
40#include <rtems/score/states.h>
41#include <rtems/score/thread.h>
42#include <rtems/score/threadq.h>
43#if defined(RTEMS_MULTIPROCESSING)
44#include <rtems/score/mpci.h>
45#endif
46#include <rtems/score/sysstate.h>
47
48#include <rtems/score/interr.h>
49
50/*
51 *  rtems_semaphore_release
52 *
53 *  This directive allows a thread to release a semaphore.
54 *
55 *  Input parameters:
56 *    id - semaphore id
57 *
58 *  Output parameters:
59 *    RTEMS_SUCCESSFUL - if successful
60 *    error code        - if unsuccessful
61 */
62
63#if defined(RTEMS_MULTIPROCESSING)
64#define MUTEX_MP_SUPPORT _Semaphore_Core_mutex_mp_support
65#else
66#define MUTEX_MP_SUPPORT NULL
67#endif
68
69rtems_status_code rtems_semaphore_release(
70  rtems_id   id
71)
72{
73  register Semaphore_Control *the_semaphore;
74  Objects_Locations           location;
75  CORE_mutex_Status           mutex_status;
76  CORE_semaphore_Status       semaphore_status;
77
78  the_semaphore = _Semaphore_Get( id, &location );
79  switch ( location ) {
80
81    case OBJECTS_LOCAL:
82      if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
83        mutex_status = _CORE_mutex_Surrender(
84          &the_semaphore->Core_control.mutex,
85          id,
86          MUTEX_MP_SUPPORT
87        );
88        _Thread_Enable_dispatch();
89        return _Semaphore_Translate_core_mutex_return_code( mutex_status );
90      } else {
91        semaphore_status = _CORE_semaphore_Surrender(
92          &the_semaphore->Core_control.semaphore,
93          id,
94          MUTEX_MP_SUPPORT
95        );
96        _Thread_Enable_dispatch();
97        return
98          _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
99      }
100
101#if defined(RTEMS_MULTIPROCESSING)
102    case OBJECTS_REMOTE:
103      return _Semaphore_MP_Send_request_packet(
104        SEMAPHORE_MP_RELEASE_REQUEST,
105        id,
106        0,                               /* Not used */
107        MPCI_DEFAULT_TIMEOUT
108      );
109#endif
110
111    case OBJECTS_ERROR:
112      break;
113  }
114
115  return RTEMS_INVALID_ID;
116}
Note: See TracBrowser for help on using the repository browser.