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

Subversion Repositories openrisc_me

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  Thread Queue 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 the file LICENSE in this distribution or at
10
 *  http://www.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: threadqextractpriority.c,v 1.2 2001-09-27 11:59:34 chris Exp $
13
 */
14
 
15
#include <rtems/system.h>
16
#include <rtems/score/chain.h>
17
#include <rtems/score/isr.h>
18
#include <rtems/score/object.h>
19
#include <rtems/score/states.h>
20
#include <rtems/score/thread.h>
21
#include <rtems/score/threadq.h>
22
#include <rtems/score/tqdata.h>
23
 
24
/*PAGE
25
 *
26
 *  _Thread_queue_Extract_priority
27
 *
28
 *  This routine removes a specific thread from the specified threadq,
29
 *  deletes any timeout, and unblocks the thread.
30
 *
31
 *  Input parameters:
32
 *    the_thread_queue - pointer to a threadq header
33
 *    the_thread       - pointer to a thread control block
34
 *
35
 *  Output parameters: NONE
36
 *
37
 *  INTERRUPT LATENCY:
38
 *    EXTRACT_PRIORITY
39
 */
40
 
41
void _Thread_queue_Extract_priority(
42
  Thread_queue_Control *the_thread_queue,
43
  Thread_Control       *the_thread
44
)
45
{
46
  ISR_Level              level;
47
  Chain_Node     *the_node;
48
  Chain_Node     *next_node;
49
  Chain_Node     *previous_node;
50
  Thread_Control *new_first_thread;
51
  Chain_Node     *new_first_node;
52
  Chain_Node     *new_second_node;
53
  Chain_Node     *last_node;
54
 
55
  the_node = (Chain_Node *) the_thread;
56
  _ISR_Disable( level );
57
  if ( _States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
58
    next_node     = the_node->next;
59
    previous_node = the_node->previous;
60
 
61
    if ( !_Chain_Is_empty( &the_thread->Wait.Block2n ) ) {
62
      new_first_node   = the_thread->Wait.Block2n.first;
63
      new_first_thread = (Thread_Control *) new_first_node;
64
      last_node        = the_thread->Wait.Block2n.last;
65
      new_second_node  = new_first_node->next;
66
 
67
      previous_node->next      = new_first_node;
68
      next_node->previous      = new_first_node;
69
      new_first_node->next     = next_node;
70
      new_first_node->previous = previous_node;
71
 
72
      if ( !_Chain_Has_only_one_node( &the_thread->Wait.Block2n ) ) {
73
                                          /* > two threads on 2-n */
74
        new_second_node->previous =
75
                  _Chain_Head( &new_first_thread->Wait.Block2n );
76
        new_first_thread->Wait.Block2n.first = new_second_node;
77
 
78
        new_first_thread->Wait.Block2n.last = last_node;
79
        last_node->next = _Chain_Tail( &new_first_thread->Wait.Block2n );
80
      }
81
    } else {
82
      previous_node->next = next_node;
83
      next_node->previous = previous_node;
84
    }
85
 
86
    if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
87
      _ISR_Enable( level );
88
      _Thread_Unblock( the_thread );
89
    } else {
90
      _Watchdog_Deactivate( &the_thread->Timer );
91
      _ISR_Enable( level );
92
      (void) _Watchdog_Remove( &the_thread->Timer );
93
      _Thread_Unblock( the_thread );
94
    }
95
 
96
#if defined(RTEMS_MULTIPROCESSING)
97
    if ( !_Objects_Is_local_id( the_thread->Object.id ) )
98
      _Thread_MP_Free_proxy( the_thread );
99
#endif
100
  }
101
  else
102
    _ISR_Enable( level );
103
}
104
 

powered by: WebSVN 2.1.0

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