diff options
author | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-04-30 22:18:46 +0000 |
---|---|---|
committer | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-04-30 22:18:46 +0000 |
commit | d4246be678873221e7ffe08d59084e6759b0650c (patch) | |
tree | b61b3014ca11cee82118ccd1f2a8929ae3dc8ff5 | |
parent | 4845ad26132c2f90f9a89fc9da888b6fc6aaefb6 (diff) | |
download | ATCD-d4246be678873221e7ffe08d59084e6759b0650c.tar.gz |
added new file
-rw-r--r-- | TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.cpp | 74 | ||||
-rw-r--r-- | TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.h | 36 |
2 files changed, 110 insertions, 0 deletions
diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.cpp new file mode 100644 index 00000000000..7485812dbb7 --- /dev/null +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.cpp @@ -0,0 +1,74 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file FailureAwareWCRT.cpp + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#include "FailureAwareWCRT.h" + +FailureAwareWCRT::FailureAwareWCRT (const TASK_LIST & tasks, + const REPLICA_GROUPS & rep_groups) + : tasks_ (tasks), + replica_finder_ (rep_groups) +{ +} + +double +FailureAwareWCRT::operator () (double previous, + const PROCESSOR_SET & failures) +{ + // find all tasks that need to become active + std::set<Taskname> active_tasks; + for (TASK_LIST::iterator t_it = tasks_.begin (); + t_it != tasks_.end (); + ++t_it) + { + // check in the replica map if all previous tasks get activated + // and switch the task to primary if this is the case + PROCESSOR_SET necessary_failures = replica_finder_ (*t_it); + + PROCESSOR_SET difference; + std::set_intersection (failures.begin (), + failures.end (), + necessary_failures.begin (), + necessary_failures.end (), + std::inserter (difference, + difference.begin ())); + + // If all necessary processors are failing, make the task primary. + // This is the case if all necessary_failures are contained in the + // difference set. + if (difference.size () == necessary_failures.size ()) + { + active_tasks.insert (t_it->name); + + // activate relevant tasks + t_it->role = PRIMARY; + } + } + + double result = ctt_ (tasks_); + + // deactivate relevant tasks + for (TASK_LIST::iterator t_it = tasks_.begin (); + t_it != tasks_.end (); + ++t_it) + { + if (active_tasks.find (t_it->name) != active_tasks.end ()) + { + t_it->role = BACKUP; + } + } + + if ((result > .0) && (previous != .0)) + return std::max(result, + previous); + + return .0; +} diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.h new file mode 100644 index 00000000000..049c38dda6a --- /dev/null +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/DeCoRAM/src/FailureAwareWCRT.h @@ -0,0 +1,36 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file FailureAwareWCRT.h + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef FAILURE_AWARE_WCRT_H_ +#define FAILURE_AWARE_WCRT_H_ + +#include "CTT_Enhanced.h" +#include "Scheduler.h" + +class FailureAwareWCRT : public std::binary_function <double, + PROCESSOR_SET, + double> +{ +public: + FailureAwareWCRT (const TASK_LIST & tasks, + const REPLICA_GROUPS & rep_groups); + + double operator () (double previous, + const PROCESSOR_SET & failures); + +private: + CTT_Enhanced ctt_; + TASK_LIST tasks_; + ReplicaFinder replica_finder_; +}; + +#endif /* FAILURE_AWARE_WCRT_H_ */ |