source: rtems/cpukit/score/src/threadyieldprocessor.c @ fa6b0f5

4.104.114.84.95
Last change on this file since fa6b0f5 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.0 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_Yield_processor
36 *
37 *  This kernel routine will remove the running THREAD from the ready chain
38 *  and place it immediatly at the rear of this chain.  Reset timeslice
39 *  and yield the processor functions both use this routine, therefore if
40 *  reset is TRUE and this is the only thread on the chain then the
41 *  timeslice counter is reset.  The heir THREAD will be updated if the
42 *  running is also the currently the heir.
43 *
44 *  Input parameters:   NONE
45 *
46 *  Output parameters:  NONE
47 *
48 *  INTERRUPT LATENCY:
49 *    ready chain
50 *    select heir
51 */
52
53void _Thread_Yield_processor( void )
54{
55  ISR_Level       level;
56  Thread_Control *executing;
57  Chain_Control  *ready;
58
59  executing = _Thread_Executing;
60  ready     = executing->ready;
61  _ISR_Disable( level );
62    if ( !_Chain_Has_only_one_node( ready ) ) {
63      _Chain_Extract_unprotected( &executing->Object.Node );
64      _Chain_Append_unprotected( ready, &executing->Object.Node );
65
66      _ISR_Flash( level );
67
68      if ( _Thread_Is_heir( executing ) )
69        _Thread_Heir = (Thread_Control *) ready->first;
70      _Context_Switch_necessary = TRUE;
71    }
72    else if ( !_Thread_Is_heir( executing ) )
73      _Context_Switch_necessary = TRUE;
74
75  _ISR_Enable( level );
76}
Note: See TracBrowser for help on using the repository browser.