source: rtems/cpukit/score/src/scheduleredfyield.c @ 5472ad41

4.115
Last change on this file since 5472ad41 was 5472ad41, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 11, 2011 at 8:52:37 PM

2011-09-11 Petr Benes <benesp16@…>

PR 1896/cpukit

  • sapi/include/confdefs.h, score/Makefile.am, score/preinstall.am: Add Earliest Deadline First (EDF) Scheduling Algorithm implementation.
  • score/include/rtems/score/scheduleredf.h, score/src/scheduleredf.c, score/src/scheduleredfallocate.c, score/src/scheduleredfblock.c, score/src/scheduleredfenqueue.c, score/src/scheduleredfenqueuefirst.c, score/src/scheduleredfextract.c, score/src/scheduleredffree.c, score/src/scheduleredfprioritycompare.c, score/src/scheduleredfreleasejob.c, score/src/scheduleredfschedule.c, score/src/scheduleredfunblock.c, score/src/scheduleredfupdate.c, score/src/scheduleredfyield.c: New files.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  Copyright (C) 2011 Petr Benes.
3 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/score/isr.h>
18#include <rtems/score/scheduler.h>
19#include <rtems/score/scheduleredf.h>
20#include <rtems/score/thread.h>
21
22void _Scheduler_EDF_Yield(void)
23{
24  Scheduler_EDF_Per_thread *first_info;
25  RBTree_Node              *first_node;
26  ISR_Level                 level;
27
28  Thread_Control *executing  = _Thread_Executing;
29  Scheduler_EDF_Per_thread *executing_info =
30    (Scheduler_EDF_Per_thread *) executing->scheduler_info;
31  RBTree_Node *executing_node = &(executing_info->Node);
32
33  _ISR_Disable( level );
34
35  if ( !_RBTree_Has_only_one_node(&_Scheduler_EDF_Ready_queue) ) {
36    /*
37     * The RBTree has more than one node, enqueue behind the tasks
38     * with the same priority in case there are such ones.
39     */
40    _RBTree_Extract( &_Scheduler_EDF_Ready_queue, executing_node );
41    _RBTree_Insert( &_Scheduler_EDF_Ready_queue, executing_node );
42
43    _ISR_Flash( level );
44
45    if ( _Thread_Is_heir( executing ) ) {
46      first_node = _RBTree_Peek( &_Scheduler_EDF_Ready_queue, RBT_LEFT );
47      first_info =
48        _RBTree_Container_of(first_node, Scheduler_EDF_Per_thread, Node);
49      _Thread_Heir = first_info->thread;
50    }
51    _Thread_Dispatch_necessary = true;
52  }
53  else if ( !_Thread_Is_heir( executing ) )
54    _Thread_Dispatch_necessary = true;
55
56  _ISR_Enable( level );
57}
Note: See TracBrowser for help on using the repository browser.