source: rtems/c/src/exec/score/src/threadrotatequeue.c @ eb02f47

4.104.114.84.95
Last change on this file since eb02f47 was eb02f47, checked in by Joel Sherrill <joel.sherrill@…>, on 11/10/99 at 13:48:27

Committed modifications from ITRON Task and Task Dependendent Synchronization
Working Group. Included are tests.

  • Property mode set to 100644
File size: 2.1 KB
Line 
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_Rotate_Ready_Queue
33 *
34 *  This kernel routine will rotate the ready queue.
35 *  remove the running THREAD from the ready chain
36 *  and place it immediatly at the rear of this chain.  Reset timeslice
37 *  and yield the processor functions both use this routine, therefore if
38 *  reset is TRUE and this is the only thread on the chain then the
39 *  timeslice counter is reset.  The heir THREAD will be updated if the
40 *  running is also the currently the heir.
41 *
42 *  Input parameters: 
43 *      Priority of the queue we wish to modify.
44 *
45 *  Output parameters:  NONE
46 *
47 *  INTERRUPT LATENCY:
48 *    ready chain
49 *    select heir
50 */
51
52void _Thread_Rotate_Ready_Queue(
53  Priority_Control  priority
54)
55{
56  ISR_Level       level;
57  Thread_Control *executing;
58  Chain_Control  *ready;
59  Chain_Node     *node;
60
61  ready     = &_Thread_Ready_chain[ priority ];
62  executing = _Thread_Executing;
63
64  if ( ready == executing->ready ) {
65    _Thread_Yield_processor();
66    return;
67  }
68
69  _ISR_Disable( level );
70
71  if ( !_Chain_Is_empty( ready ) ) {
72    if (!_Chain_Has_only_one_node( ready ) ) {
73      node = _Chain_Get_first_unprotected( ready );
74      _Chain_Append_unprotected( ready, node );
75    }
76  }
77
78  _ISR_Flash( level );
79
80  if ( _Thread_Heir->ready == ready )
81    _Thread_Heir = (Thread_Control *) ready->first;
82
83  if ( executing != _Thread_Heir )
84    _Context_Switch_necessary = TRUE;
85
86  _ISR_Enable( level );
87}
88
89
90
91
92
93
Note: See TracBrowser for help on using the repository browser.