source: rtems/cpukit/score/src/corespinlockrelease.c @ dafa5d88

5
Last change on this file since dafa5d88 was 48fed9a, checked in by Sebastian Huber <sebastian.huber@…>, on 06/25/15 at 12:11:53

score: Simplify <rtems/system.h>

Drop the <rtems/score/percpu.h> include since this file exposes a lot of
implementation details.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Release a Spinlock
5 * @ingroup ScoreSpinlock
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2006.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/corespinlockimpl.h>
22#include <rtems/score/percpu.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/watchdog.h>
25
26CORE_spinlock_Status _CORE_spinlock_Release(
27  CORE_spinlock_Control  *the_spinlock
28)
29{
30  ISR_Level level;
31
32  _ISR_Disable( level );
33
34    /*
35     *  It must locked before it can be unlocked.
36     */
37    if ( the_spinlock->lock == CORE_SPINLOCK_UNLOCKED ) {
38      _ISR_Enable( level );
39      return CORE_SPINLOCK_NOT_LOCKED;
40    }
41
42    /*
43     *  It must locked by the current thread before it can be unlocked.
44     */
45    if ( the_spinlock->holder != _Thread_Executing->Object.id ) {
46      _ISR_Enable( level );
47      return CORE_SPINLOCK_NOT_HOLDER;
48    }
49
50    /*
51     *  Let it be unlocked.
52     */
53    the_spinlock->users -= 1;
54    the_spinlock->lock   = CORE_SPINLOCK_UNLOCKED;
55    the_spinlock->holder = 0;
56
57  _ISR_Enable( level );
58  return CORE_SPINLOCK_SUCCESSFUL;
59}
Note: See TracBrowser for help on using the repository browser.