source: rtems/cpukit/score/src/threadclearstate.c @ 0a97ba5b

5
Last change on this file since 0a97ba5b 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 Clear Thread state
5 *  @ingroup ScoreThread
6 */
7
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#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/threadimpl.h>
22#include <rtems/score/assert.h>
23#include <rtems/score/schedulerimpl.h>
24
25States_Control _Thread_Clear_state(
26  Thread_Control *the_thread,
27  States_Control  state
28)
29{
30  ISR_lock_Context lock_context;
31  States_Control   previous_state;
32
33  _Assert( state != 0 );
34
35  _Scheduler_Acquire( the_thread, &lock_context );
36
37  previous_state = the_thread->current_state;
38
39  if ( ( previous_state & state ) != 0 ) {
40    States_Control next_state;
41
42    next_state = _States_Clear( state, previous_state );
43    the_thread->current_state = next_state;
44
45    if ( _States_Is_ready( next_state ) ) {
46      _Scheduler_Unblock( the_thread );
47    }
48  }
49
50  _Scheduler_Release( the_thread, &lock_context );
51
52  return previous_state;
53}
Note: See TracBrowser for help on using the repository browser.