source: rtems/cpukit/score/src/scheduleredf.c @ 3891983

4.115
Last change on this file since 3891983 was 3891983, checked in by Sebastian Huber <sebastian.huber@…>, on 04/03/14 at 09:53:48

score: Add and use Scheduler_EDF_Control

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Scheduler EDF Initialize and Support
5 * @ingroup ScoreScheduler
6 */
7
8/*
9 *  Copyright (C) 2011 Petr Benes.
10 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/scheduleredf.h>
22#include <rtems/score/schedulerimpl.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/wkspace.h>
25
26static int _Scheduler_EDF_RBTree_compare_function
27(
28  const RBTree_Node* n1,
29  const RBTree_Node* n2
30)
31{
32  Priority_Control value1 = _RBTree_Container_of
33    (n1,Scheduler_EDF_Per_thread,Node)->thread->current_priority;
34  Priority_Control value2 = _RBTree_Container_of
35    (n2,Scheduler_EDF_Per_thread,Node)->thread->current_priority;
36
37  /*
38   * This function compares only numbers for the red-black tree,
39   * but priorities have an opposite sense.
40   */
41  return (-1)*_Scheduler_Priority_compare(value1, value2);
42}
43
44void _Scheduler_EDF_Initialize(void)
45{
46  Scheduler_EDF_Control *scheduler =
47    _Workspace_Allocate_or_fatal_error( sizeof( *scheduler ) );
48
49  _RBTree_Initialize_empty(
50    &scheduler->Ready,
51    _Scheduler_EDF_RBTree_compare_function,
52    0
53  );
54
55  _Scheduler.information = scheduler;
56}
Note: See TracBrowser for help on using the repository browser.