RTEMS
threadsetstate.c
Go to the documentation of this file.
1 
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 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include <rtems/score/threadimpl.h>
25 #include <rtems/score/assert.h>
27 
29  Thread_Control *the_thread,
30  States_Control state
31 )
32 {
33  States_Control previous_state;
34  States_Control next_state;
35 
36  _Assert( state != 0 );
37  _Assert( _Thread_State_is_owner( the_thread ) );
38 
39  previous_state = the_thread->current_state;
40  next_state = _States_Set( state, previous_state);
41  the_thread->current_state = next_state;
42 
43  if ( _States_Is_ready( previous_state ) ) {
44  _Scheduler_Block( the_thread );
45  }
46 
47  return previous_state;
48 }
49 
51  Thread_Control *the_thread,
52  States_Control state
53 )
54 {
55  ISR_lock_Context lock_context;
56  States_Control previous_state;
57 
58  _Thread_State_acquire( the_thread, &lock_context );
59  previous_state = _Thread_Set_state_locked( the_thread, state );
60  _Thread_State_release( the_thread, &lock_context );
61 
62  return previous_state;
63 }
Inlined Routines Associated with the Manipulation of the Scheduler.
static __inline__ void _Thread_State_release(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the lock context and enables interrupts.
Definition: threadimpl.h:592
uint32_t States_Control
Definition: states.h:46
Information for the Assert Handler.
static __inline__ States_Control _States_Set(States_Control states_to_set, States_Control current_state)
Returns the result of setting the states to set to the given state.
Definition: statesimpl.h:157
States_Control _Thread_Set_state_locked(Thread_Control *the_thread, States_Control state)
Sets the specified thread state without locking the lock context.
States_Control current_state
Definition: thread.h:749
static __inline__ void _Scheduler_Block(Thread_Control *the_thread)
Blocks a thread with respect to the scheduler.
States_Control _Thread_Set_state(Thread_Control *the_thread, States_Control state)
Sets the specified thread state.
static __inline__ bool _States_Is_ready(States_Control the_states)
Checks if the state is ready.
Definition: statesimpl.h:195
Inlined Routines from the Thread Handler.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
static __inline__ void _Thread_State_acquire(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Disables interrupts and acquires the lock_context.
Definition: threadimpl.h:542
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100