source: rtems/c/src/exec/score/src/threadchangepriority.c @ 05df0a8

4.104.114.84.95
Last change on this file since 05df0a8 was 05df0a8, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/99 at 20:41:13

Thread Handler split into multiple files. Eventually, as RTEMS is
split into one function per file, this will decrease the size of executables.

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