courseware abstract rtos modelling for multi-processor soc using systemc prof. jan madsen...
TRANSCRIPT
courseware
Abstract RTOS Modelling for Multi-Processor SoC using
SystemCProf. Jan Madsen
Informatics and Mathematical ModellingTechnical University of Denmark
Richard Petersens Plads, Building 321DK2800 Lyngby, Denmark
Jan Madsen 3SoC-MOBINET courseware
Principles of mapping
12
3
Partitioning/clusteringBreak processes toincrease parallelism
Cluster processes toreduce communication
Allocation
a b
MappingSchedulingCommunication
1
3 2
a
b 1 2 & 3
deadline
Jan Madsen 6SoC-MOBINET courseware
Uni-processor ...
rtos
a
Framework to experiment with different RTOS strategies
Focus on analysis of timing and resource sharing
Abstract software model, i.e. no behavior/functionality
Easy to create tasks and implement RTOS models
Based on SystemC
Jan Madsen 10SoC-MOBINET courseware
System model
Task messages: ready finished
RTOS commands: run preemept Resume
rtos
task
scheduler
links
Jan Madsen 11SoC-MOBINET courseware
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);
rtosidentifier
period
priority
offsetWCET
Jan Madsen 12SoC-MOBINET courseware
Link model
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
rtos
clock
Jan Madsen 13SoC-MOBINET courseware
Task model
r1
r1 = time at which task becomes released (or active)
e1
e1 = worst case execution time (WCET)
d1 = deadline, task should complete before this!
d1s1
s1 = time at which task starts its execution
T1
T1 = period, minimum time between task releases
1
o1 = offset (or phase) for first released
o1
Jan Madsen 14SoC-MOBINET courseware
Task model
idle
running preempt
ready
Cp>0 !run
!resume
run
Cp==0 ready
preempt
resume
Cr==0finish
& Cr>0!preempt
Jan Madsen 15SoC-MOBINET courseware
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;
Task model - SystemC
new_state
state
Jan Madsen 16SoC-MOBINET courseware
Scheduling model
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
rtosscheduler
Jan Madsen 17SoC-MOBINET courseware
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 { }}
Scheduling model - SystemC
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
Rate monotonic scheduling
Jan Madsen 18SoC-MOBINET courseware
An example
p3
p2
p1
50
40
30
0 20 30 40 50 6010
1
3
2
1
2
3
priorityeiTi
1030
1040
1250
2
3
1
Jan Madsen 20SoC-MOBINET courseware
Extending the task model
Varying execution times [emin:emax]
r1 emin d1s1 T1
1
emax
Jan Madsen 21SoC-MOBINET courseware
Extending the task model
Varying execution times [emin:emax]
Context switching Data dependencies
r1 d1s1 T1
1
Jan Madsen 28SoC-MOBINET courseware
Example
1
34
2
oi Ti ei
0 4 2
0 6 2+2
4 6 3
1
2
4
3
b
os
4
a
os
1
2
3
Jan Madsen 29SoC-MOBINET courseware
Dynamic scheduling
b
os
4
a
os
1
2
3
0 4 6 8 102 14 1612
1
2a
0 4 6 8 102 14 1612
3
4b
RM RM
Jan Madsen 30SoC-MOBINET courseware
Changing synchronization protocol
0 4 6 8 102
0 4 6 8 102
14 1612
14 1612
b
os
4
a
os
1
2
31
3
2
4
a
b
RM EDF
Jan Madsen 31SoC-MOBINET courseware
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
changing the priority list increasing the number of processor reducing execution times weakening the precedence constraints
May increase the scheduling length!
Jan Madsen 32SoC-MOBINET courseware
Example of anomalies
1
3
2
4 5
1
3
2
4 5
Reduce e1 of task 1
a
b
a
b
Task 2 and 4 are sharing a resource, i.e. mutually exclusion
1 3
42
5
Jan Madsen 33SoC-MOBINET courseware
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 34SoC-MOBINET courseware
Network-on-Chip extension
b
os
a
os
c
os
L1 L2
L3
S1 S2 S3
1
3
4
2
3
2 5
415mx
mz
my
mx: S1,L3,S3,L2,S2
Jan Madsen 36SoC-MOBINET courseware
Design space exploration
bus
4,5c
3b
1,2a
b
a
c
bus
1
4
3
2
5
xy z
b
a
c
bus
1
4
3
2
5
xyz
L1
L2
b
a
c
L3
2
4
3
1
5
x
y
z
zL1
L2
b
a
c
L3
1
4 5
3
2
x
x
z
y
QoS AwareAny traffic from a has higher priority
1,2a
3b
4,5c
L1 L2
L3
L1
L2
b
a
c
L3
2
4 5
3
1
x
x
z
yTiming Aware
L3L4 y xz
b
a
c
bus
1
4
32
5
zyx
L1
L2
b
a
c 1
4
32
5
z
L1
L3
b
a
c 1
4
32
5
z
xx
xy
Allocation AwareSwap task on PEs to: 2,3 | 4,5 | 1
3b
4,5cL1 L2
L3L4
L1
L2
b
a
c
L3
2
4
3
1
5
x
y
z
z
1,2a
Jan Madsen 37SoC-MOBINET courseware
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 38SoC-MOBINET courseware
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