summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/Forward_Ranking_Scheduler.h
blob: 6dc20e8ac927ff8362f47eb5f5af2b08b614b947 (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
// -*- C++ -*-

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

#ifndef FORWARD_RANKING_SCHEDULER_H_
#define FORWARD_RANKING_SCHEDULER_H_

#include "Scheduler.h"

typedef std::map <Taskname, PROCESSOR_SET> FAILURE_MAP;

/**
 * @class FailureMapFinder
 *
 * @brief Functor that uses the replica group to determine the
 *        processors that need to fail in order for a given backup
 *        task to become active
 */
class FailureMapFinder : public std::unary_function <Task,
                                                     PROCESSOR_SET>
{
public:
  FailureMapFinder (const FAILURE_MAP & failure_map);

  PROCESSOR_SET operator () (const Task & task);

private:
  const FAILURE_MAP & failure_map_;
};

class Forward_Ranking_Scheduler : public Scheduler
{
public:
  /// default ctor
  Forward_Ranking_Scheduler (const PROCESSOR_LIST & processors,
                             unsigned int max_failures);

  virtual double schedule_task (const Task & task,
                                const Processor & processor);

protected:
  virtual void update_schedule (const Task & task,
                                const Processor & processor);

private:
  void update_failure_map (const Task & task,
                           const Processor & processor);

  bool check_for_existing_replicas (const Task & task,
                                     const Processor & processor);

  PROCESSOR_SET replica_processors (const Task & task);

  PROCESSOR_SET relevant_processors (const TASK_LIST & tasks,
                                     const PROCESSOR_SET & ignored_processors);

  PROCESSOR_SETS permute_processors (const PROCESSOR_SET & fixed,
                                     const PROCESSOR_SET & exchangeable,
                                     unsigned int failure_number);

  double accumulate_wcrt (const TASK_LIST & tasks,
                          const PROCESSOR_SETS & scenarios);

private:
  FAILURE_MAP failure_map_;
};

std::ostream & operator<< (std::ostream & ostr, 
                           const FAILURE_MAP & fm);

#endif /* FORWARD_RANKING_SCHEDULER_H_ */