source: rtems/cpukit/score/src/threadchangepriority.c @ a8eed23

4.104.114.84.95
Last change on this file since a8eed23 was a8eed23, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/27/05 at 05:57:05

Include config.h.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 *  Thread Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/apiext.h>
21#include <rtems/score/context.h>
22#include <rtems/score/interr.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/object.h>
25#include <rtems/score/priority.h>
26#include <rtems/score/states.h>
27#include <rtems/score/sysstate.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/threadq.h>
30#include <rtems/score/userext.h>
31#include <rtems/score/wkspace.h>
32
33/*PAGE
34 *
35 *  _Thread_Change_priority
36 *
37 *  This kernel routine changes the priority of the thread.  The
38 *  thread chain is adjusted if necessary.
39 *
40 *  Input parameters:
41 *    the_thread   - pointer to thread control block
42 *    new_priority - ultimate priority
43 *    prepend_it   - TRUE if the thread should be prepended to the chain
44 *
45 *  Output parameters:  NONE
46 *
47 *  INTERRUPT LATENCY:
48 *    ready chain
49 *    select heir
50 */
51
52void _Thread_Change_priority(
53  Thread_Control   *the_thread,
54  Priority_Control  new_priority,
55  boolean           prepend_it
56)
57{
58  ISR_Level level;
59  /* boolean   do_prepend = FALSE; */
60
61  /*
62   *  If this is a case where prepending the task to its priority is
63   *  potentially desired, then we need to consider whether to do it.
64   *  This usually occurs when a task lowers its priority implcitly as
65   *  the result of losing inherited priority.  Normal explicit priority
66   *  change calls (e.g. rtems_task_set_priority) should always do an
67   *  append not a prepend.
68   */
69
70  /*
71   *  Techically, the prepend should conditional on the thread lowering
72   *  its priority but that does allow cxd2004 of the acvc 2.0.1 to
73   *  pass with rtems 4.0.0.  This should change when gnat redoes its
74   *  priority scheme.
75   */
76/*
77  if ( prepend_it &&
78       _Thread_Is_executing( the_thread ) &&
79       new_priority >= the_thread->current_priority )
80    prepend_it = TRUE;
81*/
82
83  _Thread_Set_transient( the_thread );
84
85  if ( the_thread->current_priority != new_priority )
86    _Thread_Set_priority( the_thread, new_priority );
87
88  _ISR_Disable( level );
89
90  the_thread->current_state =
91    _States_Clear( STATES_TRANSIENT, the_thread->current_state );
92
93  if ( ! _States_Is_ready( the_thread->current_state ) ) {
94    /*
95     *  XXX If a task is to be reordered while blocked on a priority
96     *  XXX priority ordered thread queue, then this is where that
97     *  XXX should occur.
98     */
99    _ISR_Enable( level );
100    return;
101  }
102
103  _Priority_Add_to_bit_map( &the_thread->Priority_map );
104  if ( prepend_it )
105    _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node );
106  else
107    _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
108
109  _ISR_Flash( level );
110
111  _Thread_Calculate_heir();
112
113  if ( !_Thread_Is_executing_also_the_heir() &&
114       _Thread_Executing->is_preemptible )
115    _Context_Switch_necessary = TRUE;
116  _ISR_Enable( level );
117}
Note: See TracBrowser for help on using the repository browser.