4.115
Last change
on this file since 2369b10 was
c499856,
checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47
|
Change all references of rtems.com to rtems.org.
|
-
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/system.h> |
---|
22 | #include <rtems/score/corespinlockimpl.h> |
---|
23 | #include <rtems/score/thread.h> |
---|
24 | #include <rtems/score/watchdog.h> |
---|
25 | |
---|
26 | CORE_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.