RTEMS
threadclearstate.c
Go to the documentation of this file.
1 
8 /*
9  * COPYRIGHT (c) 1989-2011.
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 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
21 #include <rtems/score/threadimpl.h>
22 #include <rtems/score/assert.h>
24 
26  Thread_Control *the_thread,
27  States_Control state
28 )
29 {
30  States_Control previous_state;
31 
32  _Assert( state != 0 );
33  _Assert( _Thread_State_is_owner( the_thread ) );
34 
35  previous_state = the_thread->current_state;
36 
37  if ( ( previous_state & state ) != 0 ) {
38  States_Control next_state;
39 
40  next_state = _States_Clear( state, previous_state );
41  the_thread->current_state = next_state;
42 
43  if ( _States_Is_ready( next_state ) ) {
44  _Scheduler_Unblock( the_thread );
45  }
46  }
47 
48  return previous_state;
49 }
50 
52  Thread_Control *the_thread,
53  States_Control state
54 )
55 {
56  ISR_lock_Context lock_context;
57  States_Control previous_state;
58 
59  _Thread_State_acquire( the_thread, &lock_context );
60  previous_state = _Thread_Clear_state_locked( the_thread, state );
61  _Thread_State_release( the_thread, &lock_context );
62 
63  return previous_state;
64 }
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__ void _Scheduler_Unblock(Thread_Control *the_thread)
Unblocks a thread with respect to the scheduler.
States_Control _Thread_Clear_state(Thread_Control *the_thread, States_Control state)
Clears the specified thread state.
States_Control current_state
Definition: thread.h:749
static __inline__ bool _States_Is_ready(States_Control the_states)
Checks if the state is ready.
Definition: statesimpl.h:195
States_Control _Thread_Clear_state_locked(Thread_Control *the_thread, States_Control state)
Clears the specified thread state without locking the lock context.
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
static __inline__ States_Control _States_Clear(States_Control states_to_clear, States_Control current_state)
Clears the states into the passed current state and returns the result.
Definition: statesimpl.h:176