summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/Schedule.h
blob: 9745372654d1b1aa2408e4e81aaec0157440cb9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Schedule.h
 *
 *  $Id$
 *
 *  @author  Friedhelm Wolf (fwolf@dre.vanderbilt.edu)
 */
//=============================================================================

#ifndef SCHEDULE_H_
#define SCHEDULE_H_

#include <set>
#include "Algorithms.h"

typedef std::set <Processor> PROCESSOR_SET;
typedef std::set <Taskname> TASKNAME_SET;

std::ostream & operator<< (std::ostream & ostr, const TASKNAME_SET & s);

// the following data structures are used within FTRMFF to keep track
// of temporary task placement results

typedef TASK_LIST Schedule_Entry;
typedef std::map <Processor, Schedule_Entry> SCHEDULE;

std::ostream & operator<< (std::ostream & ostr, const SCHEDULE & s);

SCHEDULE read_schedule (std::istream & istr);

SCHEDULE create_schedule (const PROCESSOR_LIST & processors);

PROCESSOR_LIST get_processors (const SCHEDULE & schedule,
                               bool only_utilized = false);

unsigned long processor_usage (const SCHEDULE & schedule);

struct ScheduleResult
{
  Task task;
  Processor processor;
  double wcrt;
};

typedef std::vector <ScheduleResult> SCHEDULE_RESULT_LIST;

/// This abtract base class represents a class of algorithms that will
/// determine the rank of scheduled replicas
/// @return the number of backups that could actually be ranked
class Ranking_Algorithm : public std::binary_function <SCHEDULE_RESULT_LIST,
                                                       SCHEDULE, 
                                                       unsigned long>
{
 public:
  virtual ~Ranking_Algorithm ();

  virtual unsigned long operator () (SCHEDULE_RESULT_LIST & result_list,
                                     const SCHEDULE & schedule) = 0;
};

/// @param schedule in form of Processor -> TASK_LIST
/// @return schedule in the form Task -> Processor
SCHEDULING_MAP transform_schedule (const SCHEDULE & schedule);

/// enters a list of tasks into the schedule according to its
/// ScheduleResult entry.
void add_schedule_results (const SCHEDULE_RESULT_LIST & result_list,
                           SCHEDULE & schedule);

/// simple helper functions that creates the correct number of backup
/// tasks from a single task template
TASK_LIST create_tasks (const Task & task,
                        unsigned int backup_number);

/// helper function that creates a list of tasks that is already ranked
TASK_LIST create_ranked_tasks (const Task & task,
                               unsigned int backup_number);

struct WCRTComparison : public std::binary_function <ScheduleResult,
                                                     ScheduleResult,
                                                     bool>
{
  bool operator () (const ScheduleResult & r1,
                    const ScheduleResult & r2);
};

std::ostream & operator<< (std::ostream & ostr, const ScheduleResult & r);

#endif /* SCHEDULE_H_ */