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

4.115
Last change on this file since c71b596 was c71b596, checked in by Sebastian Huber <sebastian.huber@…>, on 07/19/13 at 13:24:04

score: Create spinlock implementation header

Move implementation specific parts of corespinlock.h and
corespinlock.inl into new header file corespinlockimpl.h. The
corespinlock.h contains now only the application visible API.

  • 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/corespinlockimpl.h>
23#include <rtems/score/states.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/watchdog.h>
26
27CORE_spinlock_Status _CORE_spinlock_Release(
28  CORE_spinlock_Control  *the_spinlock
29)
30{
31  ISR_Level level;
32
33  _ISR_Disable( level );
34
35    /*
36     *  It must locked before it can be unlocked.
37     */
38    if ( the_spinlock->lock == CORE_SPINLOCK_UNLOCKED ) {
39      _ISR_Enable( level );
40      return CORE_SPINLOCK_NOT_LOCKED;
41    }
42
43    /*
44     *  It must locked by the current thread before it can be unlocked.
45     */
46    if ( the_spinlock->holder != _Thread_Executing->Object.id ) {
47      _ISR_Enable( level );
48      return CORE_SPINLOCK_NOT_HOLDER;
49    }
50
51    /*
52     *  Let it be unlocked.
53     */
54    the_spinlock->users -= 1;
55    the_spinlock->lock   = CORE_SPINLOCK_UNLOCKED;
56    the_spinlock->holder = 0;
57
58  _ISR_Enable( level );
59  return CORE_SPINLOCK_SUCCESSFUL;
60}
Note: See TracBrowser for help on using the repository browser.