5
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Acquires the specified API mutex. |
---|
5 | * |
---|
6 | * @ingroup ScoreAPIMutex |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2007. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/score/apimutex.h> |
---|
23 | #include <rtems/score/coremuteximpl.h> |
---|
24 | #include <rtems/score/threadimpl.h> |
---|
25 | |
---|
26 | void _API_Mutex_Lock( API_Mutex_Control *the_mutex ) |
---|
27 | { |
---|
28 | Thread_Life_state previous_thread_life_state; |
---|
29 | Thread_queue_Context queue_context; |
---|
30 | |
---|
31 | previous_thread_life_state = |
---|
32 | _Thread_Set_life_protection( THREAD_LIFE_PROTECTED ); |
---|
33 | |
---|
34 | _Thread_queue_Context_initialize( &queue_context ); |
---|
35 | _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context ); |
---|
36 | _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context ); |
---|
37 | _CORE_recursive_mutex_Seize( |
---|
38 | &the_mutex->Mutex, |
---|
39 | CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS, |
---|
40 | _Thread_Executing, |
---|
41 | true, |
---|
42 | _CORE_recursive_mutex_Seize_nested, |
---|
43 | &queue_context |
---|
44 | ); |
---|
45 | |
---|
46 | if ( the_mutex->Mutex.nest_level == 0 ) { |
---|
47 | the_mutex->previous_thread_life_state = previous_thread_life_state; |
---|
48 | } |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.