4.11
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 | |
---|
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 by the current thread before it can be unlocked. |
---|
36 | */ |
---|
37 | if ( |
---|
38 | the_spinlock->lock != CORE_SPINLOCK_LOCKED |
---|
39 | || the_spinlock->holder != _Thread_Executing |
---|
40 | ) { |
---|
41 | _ISR_Enable( level ); |
---|
42 | return CORE_SPINLOCK_NOT_HOLDER; |
---|
43 | } |
---|
44 | |
---|
45 | /* |
---|
46 | * Let it be unlocked. |
---|
47 | */ |
---|
48 | the_spinlock->users -= 1; |
---|
49 | the_spinlock->lock = CORE_SPINLOCK_UNLOCKED; |
---|
50 | the_spinlock->holder = 0; |
---|
51 | |
---|
52 | _ISR_Enable( level ); |
---|
53 | return CORE_SPINLOCK_SUCCESSFUL; |
---|
54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.