source: rtems/cpukit/score/src/threadqextractpriority.c @ 2d7ae960

4.115
Last change on this file since 2d7ae960 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  Thread Queue Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-2008.
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
13#if HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <rtems/system.h>
18#include <rtems/score/chain.h>
19#include <rtems/score/isr.h>
20#include <rtems/score/object.h>
21#include <rtems/score/states.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/threadq.h>
24#include <rtems/score/tqdata.h>
25
26/*
27 *  _Thread_queue_Extract_priority
28 *
29 *  This routine removes a specific thread from the specified threadq,
30 *  deletes any timeout, and unblocks the thread.
31 *
32 *  Input parameters:
33 *    the_thread_queue - pointer to a threadq header
34 *    the_thread       - pointer to a thread control block
35 *    requeuing        - true if requeuing and should not alter timeout or state
36 *
37 *  Output parameters: NONE
38 *
39 *  INTERRUPT LATENCY:
40 *    EXTRACT_PRIORITY
41 */
42
43void _Thread_queue_Extract_priority_helper(
44  Thread_queue_Control *the_thread_queue __attribute__((unused)),
45  Thread_Control       *the_thread,
46  bool                  requeuing
47)
48{
49  ISR_Level       level;
50  Chain_Node     *head;
51  Chain_Node     *tail;
52  Chain_Node     *the_node;
53  Chain_Node     *next_node;
54  Chain_Node     *previous_node;
55  Thread_Control *new_first_thread;
56  Chain_Node     *new_first_node;
57  Chain_Node     *new_second_node;
58  Chain_Node     *last_node;
59
60  the_node = (Chain_Node *) the_thread;
61  _ISR_Disable( level );
62  if ( !_States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
63    _ISR_Enable( level );
64    return;
65  }
66
67  /*
68   *  The thread was actually waiting on a thread queue so let's remove it.
69   */
70
71  next_node     = the_node->next;
72  previous_node = the_node->previous;
73
74  if ( !_Chain_Is_empty( &the_thread->Wait.Block2n ) ) {
75    new_first_node   = _Chain_First( &the_thread->Wait.Block2n );
76    new_first_thread = (Thread_Control *) new_first_node;
77    last_node        = _Chain_Last( &the_thread->Wait.Block2n );
78    new_second_node  = new_first_node->next;
79
80    previous_node->next      = new_first_node;
81    next_node->previous      = new_first_node;
82    new_first_node->next     = next_node;
83    new_first_node->previous = previous_node;
84
85    if ( !_Chain_Has_only_one_node( &the_thread->Wait.Block2n ) ) {
86                                        /* > two threads on 2-n */
87      head = _Chain_Head( &new_first_thread->Wait.Block2n );
88      tail = _Chain_Tail( &new_first_thread->Wait.Block2n );
89
90      new_second_node->previous = head;
91      head->next = new_second_node;
92      tail->previous = last_node;
93      last_node->next = tail;
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.