Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Object Computing Laboratory Washington University St. Louis, MO Rate-Monotonic Analysis in the C++ Type System Morgan Deters Model-Driven Embedded.

Similar presentations


Presentation on theme: "Distributed Object Computing Laboratory Washington University St. Louis, MO Rate-Monotonic Analysis in the C++ Type System Morgan Deters Model-Driven Embedded."— Presentation transcript:

1 Distributed Object Computing Laboratory Washington University St. Louis, MO Rate-Monotonic Analysis in the C++ Type System Morgan Deters Model-Driven Embedded Systems 27 May 2003 Research funded by DARPA under contract F33615-00-C-1697 Christopher Gill Ron Cytron

2 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 1 27 May 2003 Overview Context C++ template metaprograms Rate-Monotonic Analysis (RMA) RMA with Templates Extensions to the Core Approach Future Directions Concluding Remarks

3 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 2 27 May 2003 A Brief History Structured Programming Objects Middleware Components Modeling Separation of concerns Reflection/MOP Generative (configurational) Domain-Specific Languages (DSLs) GO TO

4 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 3 27 May 2003 C++ Templates template class list_node { T data; list_node * next; public: void add(T data); void remove(T data); /*... */ }; list_node node1; list_node node2; //... C++ templates/generics  reusable data structures

5 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 4 27 May 2003 C++ Templates template class list { public: void add(string data) { Guard lock; // perform the operation... } }; // in a single-threaded context list my_list; my_list.add("unsynchronized"); // in a multithreaded context list other_list; other_list.add("synchronized"); C++ templates/generics  reusable data structures  code specialization method inlining

6 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 5 27 May 2003 C++ Template Metaprogramming template struct fib { enum { a = fib ::value, b = fib ::value, value = a + b }; }; template <> struct fib { enum { value = 0 }; }; template <> struct fib { enum { value = 1 }; }; C++ templates/generics  reusable data structures  code specialization method inlining  metaprogramming constant computation template instantiation int i = fib ::value; cout << "The 6th Fibonacci " "number is " << i;

7 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 6 27 May 2003 Rate-Monotonic Analysis (RMA) Fixed-priority static scheduling  Priorities inversely proportional to period Given a set of m independent tasks (C i,T i ) The task set is feasible if [Liu & Layland 1973] C i – cost for task i T i – period for task i C i – cost for task i T i – period for task i C i /T i ≤ m(2 1/m – 1) Σ i

8 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 7 27 May 2003 Improved Feasibility Test Given a set of m independent tasks (C i,T i ) The task set is feasible if and only if [Lehoczky, Sha, & Ding 1987] C i – cost for task i T i – period for task i C i – cost for task i T i – period for task i A i, 1 ≤ i ≤ m where R = { (k,l) | 1 ≤ k ≤ i, 1 ≤ l ≤ T i /T k } min Σ (C j /(l T k )) l T k /T j ≤ 1 (k,l) ε Rj = 1 i

9 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 8 27 May 2003 RMA Template Metaprogram Perform feasibility test during compilation Determine best task set for stated requirements  Track and include dependencies Tasks become generic programming concepts Metaprogram is “reflective” on tasks Uses Alexandrescu’s typelists  compile-time variable-length linked lists of types

10 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 9 27 May 2003 Concept: Task struct my_task { typedef TYPELIST_1(another_task) dependencies; typedef my_cheap_task cheaper_alternative; static const int importance = 1000; static const bool droppable = false; static const int cost = 100; static const int period = 600; static const int start = 50; static const int deadline = 500; static void do_task(const context_object& context) { // perform the work of the task } };

11 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 10 27 May 2003 RMA Feasibility at Compile-Time struct taskA { enum { cost = 5, period = 10, /*... */ }; struct taskB { enum { cost = 5, period = 15, /*... */ }; typedef TYPELIST_2(taskA,taskB) mytasks; int main() { typedef Schedule my_schedule; STATIC_CHECK(my_schedule::feasible, Schedule_Infeasible); my_schedule::schedule(); /*... */ return 0; } No runtime cost Specialized

12 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 11 27 May 2003 RMA Computation Details Given a set of m independent tasks (C i,T i ) The task set is feasible if and only if A i, 1 ≤ i ≤ m where R = { (k,l) | 1 ≤ k ≤ i, 1 ≤ l ≤ T i /T k } min Σ (C j /(l T k )) l T k /T j ≤ 1 (k,l) ε Rj = 1 i Typelist s.t. Σ C j t /T j ≤ t j = 1 i t ε { (k,l) | 1 ≤ k ≤ i, 1 ≤ l ≤ T i /T k } E check_i support template sum_j support template get_t support template Top-level Schedule template instantiation

13 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 12 27 May 2003 Example: The check_i template template <class Head, class Tail, int m, int i> struct check_i, m, i> { enum { task_result = task_feasible, i>::Result, Result = task_result && check_i, m, i+1>::Result }; }; template struct check_i, m, m> { enum { Result = task_feasible, m>::Result }; }; Base of recursion foreach i = 1..m

14 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 13 27 May 2003 Using Tasks Also can specify dependencies & alternatives Could collect information for dynamic scheduling  Adaptation transitions typedef Schedule sched; sched::schedule(); Compile-time type error if task set infeasible Provides generic, no-overhead interface to a threading API

15 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 14 27 May 2003 Getting More from the Compiler Task dependence τ 1 requires { τ 2, τ 3 } Task alternation { τ 1,..., τ i,..., τ m } → { τ 1,..., τ i ´,..., τ m } Powerful combinations  feasibility space search  make this feasible!

16 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 15 27 May 2003 Verification at Runtime Check that analysis results still hold on execution platform Distribution soundness Feedback loop Application cost estimates profiling production code

17 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 16 27 May 2003 Adaptation at Runtime typedef TYPELIST_3(user_task, idle_task, power_monitor_task) normalSet; typedef TYPELIST_2(low_power_user_task, low_power_idle_task) lowPowerSet; void power_monitor_task::do_task(const context_object&) { if(power() <= threshold) { taskSet = new Adaptation_Traits ::adapt_to; } }; template <> class Adaptation_Traits { typedef lowPowerSet adapt_to; };

18 Washington University in St. Louis MDES 2003 Rate-Monotonic Analysis in the C++ Type SystemMorgan Deters 17 27 May 2003 Remarks Bound to C++ “Configuration negotiation” within C++  Program specialization  Automatic program reconfiguration Related work And into the future...  Assist dynamic schedulers  Pre-compute adaptation transitions

19 Morgan Deters mdeters@cs.wustl.edu Thanks ! www.cs.wustl.edu/~doc Department of Computer Science Washington University Box #1045 St. Louis, MO 63130 USA Christopher Gill cdgill@cs.wustl.edu Ron Cytron cytron@cs.wustl.edu


Download ppt "Distributed Object Computing Laboratory Washington University St. Louis, MO Rate-Monotonic Analysis in the C++ Type System Morgan Deters Model-Driven Embedded."

Similar presentations


Ads by Google