380 likes | 397 Views
Abstract RTOS Modelling for Multi-Processor SoC using SystemC. Prof. Jan Madsen Informatics and Mathematical Modelling Technical University of Denmark Richard Petersens Plads, Building 321 DK2800 Lyngby, Denmark. 3. 2. 1. 4. 1. 2. 3. 4. os. mapping. a. b. c. c. a. b.
E N D
Abstract RTOS Modelling for Multi-Processor SoC using SystemC Prof. Jan Madsen Informatics and Mathematical Modelling Technical University of Denmark Richard Petersens Plads, Building 321 DK2800 Lyngby, Denmark
3 2 1 4 1 2 3 4 os mapping a b c c a b Motivation Jan Madsen
1 2 Break processes to increase parallelism 3 Cluster processes to reduce communication deadline b a a 2 & 3 1 b Principles of mapping Partitioning/clustering Allocation Mapping Scheduling Communication 1 3 2 Jan Madsen
rtos rtos rtos rtos b c d a network Motivation Jan Madsen
rtos rtos rtos rtos b c d a network Uni-processor ... Jan Madsen
rtos a Uni-processor ... Frameworkto experiment with different RTOS strategies Focus on analysis of timingand resource sharing Abstract software model, i.e. no behavior/functionality Easyto create tasks and implement RTOS models Based on SystemC Jan Madsen
rtos a System model Jan Madsen
rtos System model Jan Madsen
rtos System model Jan Madsen
Task messages: ready finished RTOS commands: run preemept Resume task rtos links scheduler System model Jan Madsen
rtos identifier offset period WCET priority System model - SystemC pa = new task("task_a",1,50,3,12,0,ready); registerTask(pa); pb = new task("task_b",2,40,2,10,0,ready); registerTask(pb); pc = new task("task_c",3,30,1,10,0,ready); registerTask(pc); Jan Madsen
Aim: Adding tasks without having to create seperate communication links Uses the SystemC master-slave library If two tasks send a message at the same time – they are executed in sequence, but in undefined order Global ”clock” is used to keep track of time clock rtos Link model Jan Madsen
r1 s1 e1 d1 T1 o1 r1 = time at which task becomes released (or active) s1 = time at which task starts its execution e1 = worst case execution time (WCET) d1 = deadline, task should complete before this! T1 = period, minimum time between task releases o1 = offset (or phase) for first released Task model 1 Jan Madsen
!run Cp>0 Cp==0 ready ready idle Cr==0 finish run !resume !preempt preempt & Cr>0 running preempt resume Task model Jan Madsen
new_state state Task model - SystemC SC_MODULE(perTask){ sc_outmaster<message_type> out_message; sc_inslave<message_type> in_command; sc_in_clk clock; sc_event newStateEvent; void next_state(); void update_state(); void get_comm_from_scheduler(); SC_HAS_PROCESS(perTask); perTask(sc_module_name name_, int id_, ...) : sc_module(name_),id(id_), ...) { SC_METHOD(next_state); sensitive << newStateEvent; SC_METHOD(update_state); sensitive << clock; SC_SLAVE(get_comm_from_scheduler,in_command); } private: t_state state, new_state; Jan Madsen
Aim: Simple way to describe the scheduling algorithm Scheduler should only handle one message at a time Rate-monotonic scheduling preemptive WCET d=T Fixed priority rtos scheduler Scheduling model Jan Madsen
Scheduling model - SystemC Rate monotonic scheduling • ti: message received from from task i • tj: message from task j with highest priority from ready list • tk: message of the currently running task void RM_scheduler::doSchedule() { ti = in_message; if (ti.comm==ready) { Q.push(ti); } else { tk.id = 0; } tj = Q.top(); if (tj.id != 0) { if (tk.id != 0) { if (tk < tj) { out_command = *(preemptTask(&tk, &Q)); tk = tj; out_command = *(runTask(&tj, &Q)); } else { } } else { tk = tj; out_command = *(runTask(&tj, &Q)); } } else { } } Jan Madsen
2 1 3 3 2 1 An example Ti ei priority 50 12 1 40 10 2 30 10 3 50 p1 40 p2 30 p3 0 10 20 30 40 50 60 Jan Madsen
2 1 3 50 p1 40 p2 30 p3 0 10 20 30 40 50 60 An example Jan Madsen
r1 s1 d1 emin emax Extending the task model • Varying execution times [emin:emax] 1 T1 Jan Madsen
r1 s1 d1 Extending the task model • Varying execution times [emin:emax] • Context switching • Data dependencies 1 T1 Jan Madsen
synchronizer scheduler Data dependencies Jan Madsen
synchronizer allocator scheduler Resource sharing Jan Madsen
rtos rtos rtos rtos b c d a network Multi-processors Jan Madsen
rtos rtos rtos rtos b c d a network Multi-processors Jan Madsen
rtos rtos rtos rtos b c Multi-processors Jan Madsen
synchronizer scheduler scheduler Multi-processors Jan Madsen
4 2 2 1 2 3 1 1 4 3 3 4 os os a b Example Jan Madsen
2 4 RM RM 1 1 3 a 2 0 2 4 6 8 10 12 14 16 3 b 4 0 2 4 6 8 10 12 14 16 Dynamic scheduling os os a b Jan Madsen
2 4 3 1 Changing synchronization protocol RM EDF 1 a 2 os os a b 0 2 4 6 8 10 12 14 16 3 b 4 0 2 4 6 8 10 12 14 16 Jan Madsen
Multi-processing anomalies • Assume a set of tasks optimally scheduled on a multiprocessor system with: • fixed number of processors • fixed execution times (ei) • precedence constraints • Then • changingthe priority list • increasingthe number of processor • reducing execution times • weakening the precedence constraints • May increase the scheduling length! Jan Madsen
2 1 2 1 3 5 4 3 4 5 1 2 a a b b 3 4 5 Example of anomalies Task 2 and 4 are sharing a resource, i.e. mutually exclusion Reduce e1 of task 1 Jan Madsen
Consequences of anomalies • Tasks may complete before their WCETs • So most on-line scheduling algorithms are subject to experience anomalies • Simple but inefficient solution: • Have tasks completing early idle Jan Madsen
1 2 3 5 2 1 4 mx my mz 3 4 5 os os os a b c L1 L2 S1 S2 S3 L3 Network-on-Chip extension mx: S1,L3,S3,L2,S2 Jan Madsen
Network-on-Chip model Jan Madsen
1,2 a 3b 4,5 c 3b 4,5 c 1,2 a 3b 4,5 c 1,2 a L1 L2 L1 L2 L3 L4 L3 a 1 2 a a 1 2 L1 L1 z x 3 b Timing Aware b b 3 4 c y x L2 L2 z y 1 2 2 2 x z bus c c 4 4 L3 L3 x y z 5 5 5 5 5 5 bus a 1 2 1 a 2 QoS Aware Any traffic from a has higher priority a 2 1 L1 L1 z x 3 b 3 b b 3 y x L2 5 4 c L2 z c 5 4 y z x c 5 4 bus x L3 z 1 1 L3 y a a a 2 L1 y x z L1 Allocation Aware Swap task on PEs to: 2,3 | 4,5 | 1 b 4 b b 3 c L2 L3 x z x c c y x z bus L3 z x L4 y 3 3 4 4 3 1 Design space exploration Jan Madsen
Summary • Simple SystemC based framework to study the dynamic behavior of a task set running under the supervision of an abstract RTOS • Synchronizer to handle data dependencies • Extension to multi-processor/RTOS systems • Network-on-Chip extension (new) • Not covered, • Allocator to handle resource sharing • Power estimation/profile • Multi-processing anomalies (in your slides) Jan Madsen
References • Scheduling in Real-Time SystemsF. Cottet, J. Delacriox, C. Kaiser, Z. MammeriJohn Wiley & Sons, 2002 • Real-Time SystemsJ. W. S. LiuPrintice Hall, 2000 • Real-Time Systems and Programming LanguagesA. Burns, A. WellingsAddison-Wesley, 2001 (third edition) • System Design with SystemCT. Grotker, S. Liao, G. Martin, S. SwanKluwer, 2002 Jan Madsen