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

4.8
Last change on this file since b72e847b was a8eed23, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/27/05 at 05:57:05

Include config.h.

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