5
Last change
on this file since bbd6d27a was
342708b9,
checked in by Sebastian Huber <sebastian.huber@…>, on 03/26/15 at 20:45:20
|
score: Return prev state in thread state set/clear
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Sets States for a Thread |
---|
5 | * |
---|
6 | * @ingroup ScoreThread |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Thread Handler / Thread Set State |
---|
11 | * |
---|
12 | * COPYRIGHT (c) 1989-2011. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.org/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #if HAVE_CONFIG_H |
---|
21 | #include "config.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <rtems/score/threadimpl.h> |
---|
25 | #include <rtems/score/assert.h> |
---|
26 | #include <rtems/score/schedulerimpl.h> |
---|
27 | |
---|
28 | States_Control _Thread_Set_state( |
---|
29 | Thread_Control *the_thread, |
---|
30 | States_Control state |
---|
31 | ) |
---|
32 | { |
---|
33 | ISR_lock_Context lock_context; |
---|
34 | States_Control previous_state; |
---|
35 | States_Control next_state; |
---|
36 | |
---|
37 | _Assert( state != 0 ); |
---|
38 | |
---|
39 | _Scheduler_Acquire( the_thread, &lock_context ); |
---|
40 | |
---|
41 | previous_state = the_thread->current_state; |
---|
42 | next_state = _States_Set( state, previous_state); |
---|
43 | the_thread->current_state = next_state; |
---|
44 | |
---|
45 | if ( _States_Is_ready( previous_state ) ) { |
---|
46 | _Scheduler_Block( the_thread ); |
---|
47 | } |
---|
48 | |
---|
49 | _Scheduler_Release( the_thread, &lock_context ); |
---|
50 | |
---|
51 | return previous_state; |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.