OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [src/] [threadchangepriority.c] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: threadchangepriority.c,v 1.2 2001-09-27 11:59:34 chris Exp $
13
 */
14
 
15
#include <rtems/system.h>
16
#include <rtems/score/apiext.h>
17
#include <rtems/score/context.h>
18
#include <rtems/score/interr.h>
19
#include <rtems/score/isr.h>
20
#include <rtems/score/object.h>
21
#include <rtems/score/priority.h>
22
#include <rtems/score/states.h>
23
#include <rtems/score/sysstate.h>
24
#include <rtems/score/thread.h>
25
#include <rtems/score/threadq.h>
26
#include <rtems/score/userext.h>
27
#include <rtems/score/wkspace.h>
28
 
29
/*PAGE
30
 *
31
 *  _Thread_Change_priority
32
 *
33
 *  This kernel routine changes the priority of the thread.  The
34
 *  thread chain is adjusted if necessary.
35
 *
36
 *  Input parameters:
37
 *    the_thread   - pointer to thread control block
38
 *    new_priority - ultimate priority
39
 *    prepend_it   - TRUE if the thread should be prepended to the chain
40
 *
41
 *  Output parameters:  NONE
42
 *
43
 *  INTERRUPT LATENCY:
44
 *    ready chain
45
 *    select heir
46
 */
47
 
48
void _Thread_Change_priority(
49
  Thread_Control   *the_thread,
50
  Priority_Control  new_priority,
51
  boolean           prepend_it
52
)
53
{
54
  ISR_Level level;
55
  /* boolean   do_prepend = FALSE; */
56
 
57
  /*
58
   *  If this is a case where prepending the task to its priority is
59
   *  potentially desired, then we need to consider whether to do it.
60
   *  This usually occurs when a task lowers its priority implcitly as
61
   *  the result of losing inherited priority.  Normal explicit priority
62
   *  change calls (e.g. rtems_task_set_priority) should always do an
63
   *  append not a prepend.
64
   */
65
 
66
  /*
67
   *  Techically, the prepend should conditional on the thread lowering
68
   *  its priority but that does allow cxd2004 of the acvc 2.0.1 to
69
   *  pass with rtems 4.0.0.  This should change when gnat redoes its
70
   *  priority scheme.
71
   */
72
/*
73
  if ( prepend_it &&
74
       _Thread_Is_executing( the_thread ) &&
75
       new_priority >= the_thread->current_priority )
76
    prepend_it = TRUE;
77
*/
78
 
79
  _Thread_Set_transient( the_thread );
80
 
81
  if ( the_thread->current_priority != new_priority )
82
    _Thread_Set_priority( the_thread, new_priority );
83
 
84
  _ISR_Disable( level );
85
 
86
  the_thread->current_state =
87
    _States_Clear( STATES_TRANSIENT, the_thread->current_state );
88
 
89
  if ( ! _States_Is_ready( the_thread->current_state ) ) {
90
    /*
91
     *  XXX If a task is to be reordered while blocked on a priority
92
     *  XXX priority ordered thread queue, then this is where that
93
     *  XXX should occur.
94
     */
95
    _ISR_Enable( level );
96
    return;
97
  }
98
 
99
  _Priority_Add_to_bit_map( &the_thread->Priority_map );
100
  if ( prepend_it )
101
    _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node );
102
  else
103
    _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
104
 
105
  _ISR_Flash( level );
106
 
107
  _Thread_Calculate_heir();
108
 
109
  if ( !_Thread_Is_executing_also_the_heir() &&
110
       _Thread_Executing->is_preemptible )
111
    _Context_Switch_necessary = TRUE;
112
  _ISR_Enable( level );
113
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.