source: rtems/cpukit/score/src/threadclearstate.c @ 78b867e2

4.10
Last change on this file since 78b867e2 was 78b867e2, checked in by Gedare Bloom <gedare@…>, on 12/21/17 at 16:49:30

score: replace current and real priority with priority node

Encapsulate the current_priority and real_priority fields of
the thread control block with a Thread_Priority_node struct.
Propagate modifications throughout the tree where the two
fields are directly accessed.

Updates #3359.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  Thread Handler / Thread Clear State
3 *
4 *  COPYRIGHT (c) 1989-2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/apiext.h>
20#include <rtems/score/context.h>
21#include <rtems/score/interr.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/score/priority.h>
25#include <rtems/score/states.h>
26#include <rtems/score/sysstate.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/threadq.h>
29#include <rtems/score/userext.h>
30#include <rtems/score/wkspace.h>
31
32/*PAGE
33 *
34 *  _Thread_Clear_state
35 *
36 *  This kernel routine clears the appropriate states in the
37 *  requested thread.  The thread ready chain is adjusted if
38 *  necessary and the Heir thread is set accordingly.
39 *
40 *  Input parameters:
41 *    the_thread - pointer to thread control block
42 *    state      - state set to clear
43 *
44 *  Output parameters:  NONE
45 *
46 *  INTERRUPT LATENCY:
47 *    priority map
48 *    select heir
49 */
50
51
52void _Thread_Clear_state(
53  Thread_Control *the_thread,
54  States_Control  state
55)
56{
57  ISR_Level       level;
58  States_Control  current_state;
59
60  _ISR_Disable( level );
61    current_state = the_thread->current_state;
62
63    if ( current_state & state ) {
64      current_state =
65      the_thread->current_state = _States_Clear( state, current_state );
66
67      if ( _States_Is_ready( current_state ) ) {
68
69        _Priority_Add_to_bit_map( &the_thread->Priority_map );
70
71        _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
72
73        _ISR_Flash( level );
74
75        /*
76         *  If the thread that was unblocked is more important than the heir,
77         *  then we have a new heir.  This may or may not result in a
78         *  context switch.
79         *
80         *  Normal case:
81         *    If the current thread is preemptible, then we need to do
82         *    a context switch.
83         *  Pseudo-ISR case:
84         *    Even if the thread isn't preemptible, if the new heir is
85         *    a pseudo-ISR system task, we need to do a context switch.
86         */
87        if ( the_thread->Priority_node.current_priority < _Thread_Heir->Priority_node.current_priority ) {
88          _Thread_Heir = the_thread;
89          if ( _Thread_Executing->is_preemptible ||
90               the_thread->Priority_node.current_priority == 0 )
91            _Context_Switch_necessary = true;
92        }
93      }
94  }
95  _ISR_Enable( level );
96}
Note: See TracBrowser for help on using the repository browser.