source: rtems/cpukit/score/src/threadqextractpriority.c @ b72e847b

4.8
Last change on this file since b72e847b was 96d0b64, checked in by Joel Sherrill <joel.sherrill@…>, on 03/05/07 at 21:01:40

2007-03-05 Joel Sherrill <joel@…>

PR 1222/cpukit

  • score/Makefile.am, score/include/rtems/score/coremutex.h, score/include/rtems/score/threadq.h, score/inline/rtems/score/coremutex.inl, score/src/coremsgsubmit.c, score/src/coremutexsurrender.c, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadhandler.c, score/src/threadinitialize.c, score/src/threadqdequeuefifo.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c, score/src/threadqextractfifo.c, score/src/threadqextractpriority.c, score/src/threadsetstate.c: Enhance so that when the prioirity of a thread that is blocked on a priority based thread queue is changed, that its placement in the queue is reevaluated based upon the new priority. This enhancement includes modifications to the SuperCore? as well as new test cases.
  • score/src/threadqrequeue.c: New file.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  Thread Queue Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-2006.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  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/chain.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/object.h>
23#include <rtems/score/states.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26#include <rtems/score/tqdata.h>
27
28/*PAGE
29 *
30 *  _Thread_queue_Extract_priority
31 *
32 *  This routine removes a specific thread from the specified threadq,
33 *  deletes any timeout, and unblocks the thread.
34 *
35 *  Input parameters:
36 *    the_thread_queue - pointer to a threadq header
37 *    the_thread       - pointer to a thread control block
38 *    requeuing        - TRUE if requeuing and should not alter timeout or state
39 *
40 *  Output parameters: NONE
41 *
42 *  INTERRUPT LATENCY:
43 *    EXTRACT_PRIORITY
44 */
45
46void _Thread_queue_Extract_priority_helper(
47  Thread_queue_Control *the_thread_queue,
48  Thread_Control       *the_thread,
49  boolean               requeuing
50)
51{
52  ISR_Level       level;
53  Chain_Node     *the_node;
54  Chain_Node     *next_node;
55  Chain_Node     *previous_node;
56  Thread_Control *new_first_thread;
57  Chain_Node     *new_first_node;
58  Chain_Node     *new_second_node;
59  Chain_Node     *last_node;
60
61  the_node = (Chain_Node *) the_thread;
62  _ISR_Disable( level );
63  if ( !_States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
64    _ISR_Enable( level );
65    return;
66  }
67
68  /*
69   *  The thread was actually waiting on a thread queue so let's remove it.
70   */
71
72  next_node     = the_node->next;
73  previous_node = the_node->previous;
74
75  if ( !_Chain_Is_empty( &the_thread->Wait.Block2n ) ) {
76    new_first_node   = the_thread->Wait.Block2n.first;
77    new_first_thread = (Thread_Control *) new_first_node;
78    last_node        = the_thread->Wait.Block2n.last;
79    new_second_node  = new_first_node->next;
80
81    previous_node->next      = new_first_node;
82    next_node->previous      = new_first_node;
83    new_first_node->next     = next_node;
84    new_first_node->previous = previous_node;
85
86    if ( !_Chain_Has_only_one_node( &the_thread->Wait.Block2n ) ) {
87                                        /* > two threads on 2-n */
88      new_second_node->previous =
89                _Chain_Head( &new_first_thread->Wait.Block2n );
90      new_first_thread->Wait.Block2n.first = new_second_node;
91
92      new_first_thread->Wait.Block2n.last = last_node;
93      last_node->next = _Chain_Tail( &new_first_thread->Wait.Block2n );
94    }
95  } else {
96    previous_node->next = next_node;
97    next_node->previous = previous_node;
98  }
99
100  /*
101   *  If we are not supposed to touch timers or the thread's state, return.
102   */
103
104  if ( requeuing ) {
105    _ISR_Enable( level );
106    return;
107  }
108
109  if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
110    _ISR_Enable( level );
111  } else {
112    _Watchdog_Deactivate( &the_thread->Timer );
113    _ISR_Enable( level );
114    (void) _Watchdog_Remove( &the_thread->Timer );
115  }
116  _Thread_Unblock( the_thread );
117
118#if defined(RTEMS_MULTIPROCESSING)
119  if ( !_Objects_Is_local_id( the_thread->Object.id ) )
120    _Thread_MP_Free_proxy( the_thread );
121#endif
122}
Note: See TracBrowser for help on using the repository browser.