Temporal reflection and reflective scheduling for the L4 microkernel - - PowerPoint PPT Presentation
Temporal reflection and reflective scheduling for the L4 microkernel - - PowerPoint PPT Presentation
Temporal reflection and reflective scheduling for the L4 microkernel WIRTES workshop - Pisa, 2 July 2007 Sergio Ruocco ruocco@disco.unimib.it Nomadis mobile systems Lab. Universit degli Studi di Milano-Bicocca Research overview Feb 2004
2
Research overview
Feb 2004 PhD Temporal Reflection, Univ. di Milano-Bicocca Apr 2004 – Apr 07 NICTA ERTOS Researcher, Sydney, Australia L4 microkernel
- temporal reflection and reflective scheduling [RTSS06]
- from real-fast to real-time [OSPERT06, OSPERT07]
- Apr. 2007 – now
Nomadis Lab. Research Fellow Università di Milano-Bicocca IMUD project: Inertial Monitoring Unit Device Research areas: – Temporal reflection and reflective real-time scheduling – non-functional / quality requirements: energy & power management – SMT/SMP real-time scheduling – L4 and Linux-based embedded real-time systems – sw engineering for device drivers, ...
3
Schedules embed assumptions
task A
deadline WCET release
Real-time schedules embed assumptions on:
CPU speed RAM speed input data IO speed task inter-dependencies etc.
4
Schedules embed assumptions
task A
deadline WCET release
Real-time schedules embed assumptions on:
CPU speed RAM speed input data IO speed task inter-dependencies etc.
assumptions can fail!
}
5
...assumptions can fail !
task A
deadline violation WCET release
6
...assumptions can fail !
task A
deadline violation WCET release
task task task A task B
7
How to adapt ? Depends on the fault !
task A
deadline violation WCET release
task task task A task task A task C / IO
?? ??
task B
8
Computational Reflection
Brian Cantwell Smith: A reflective system is a computer system able to reason about itself. Reflection and Semantics in a Procedural Language. TR 272, MIT LCS (1982) A reflective system embeds a suitable representation of itself. Such self-representation is causally-connected with the system itself.
9
Reflective scheduler
Time-driven Execution Engine Strategist
now()
T
past future
actual duration planned execution interval
System temporal behaviour ↔ object of the system
- fine-grained adaptive control of behaviour
(...and many other things we don't have time to talk about...)
actions
10
Temporal reflection
CPU / Hardware
Reflective sched. + TDE
Application + strategist
executes observes & manipulates OS Kernel Causal-connection
Temporal reflection – observe & control the system temporal behavior as an object of the system itself. – i.e., – – The real-time system becomes aware of real-time and its own behaviour. –
Sergio Ruocco, Temporal Reflection (PhD Thesis), 2004
–
11
Nice, but...
Pragmatic application (one of many...): Adaptive real-time scheduling in resource-constrained systems – fine-grained adaptation exploiting application-specific information – feedback control loop detects faults and corrects future behaviour – difficult to do with ordinary schedulers — no accurate data on faults Case study: – real-time adaptive video analysis Experimental results: – user-level implementation – ...on unmodified L4 microkernel on ARM XScale 400 MHz – microsecond-level precision & accuracy – – ... (much more in the paper, RTSS'06)
12
Adaptive video analysis
Problem: decode MPEG stream & search for a lightning before the next frame is due.
13
Application actions
CPU / Hardware
Reflective sch. + TDE
Application strategist
executes observes & manipulates OS Kernel
/* C functions implement the application functional requirements */ void mpeg2_read_action () { size = fread (buffer, 1, BUFFER_SIZE, mpgfile); mpeg2_buffer (decoder, buffer, buffer + size); } void mpeg2_parse_action () { mpeg2_parse_state = mpeg2_parse (decoder); } void analyze_action () { rectangle_rgb (info->sequence->width, info->sequence- >height, video_buffer, BRIGHTNESS_TRESHOLD, dx, dy); } void display_action () { video_buffer.display() // display the frame }
14
Read() from stream...
phase1: decoding
Application read_action()
15
Strategist actions
phase1: decoding
Strategist: handle_read()
16
Strategist actions
CPU / Hardware
Reflective sch. + TDE
Application + strategist
executes observes & manipulates OS Kernel /* C functions implement * temporal requirements * i.e., observe and compute * the system's temporal behaviour */ int handle_read() { if (size != 0) { now = lltimer_now_usec(clock); plan_parse (now, now + PARSE_LEN); } }
17
Adaptive video analysis plan
phase1: decoding
Application parse_action()
18
Strategist actions
phase1: decoding
Strategist: handle_parse()
19
Strategist actions
CPU / Hardware
Reflective sch. + TDE
Application + strategist
executes observes & manipulates OS Kernel
/* C functions implement temporal requirements * i.e., compute the system's temporal behaviour */ int handle_parse() { switch ( mpeg2_parse_state ) { case STATE_FRAME_READY: { framenum++; // compute frame display time when = first_frame_time + (framenum-1) * frame_interval[framerate]; // plan display even if 'when' is past 'now' // (i.e., missed deadline!) newa = plan_display (when,when + DISPLAY_LEN)) ... /* ... plan_analysis() ... */ }
20
Display is planned, but analysis ?
phase 2: analysis
Strategist: handle_parse()
21
Adaptive analysis planning
phase 2: analysis
time available for analysis unknown until frame ready Strategist: handle_parse()
22
Adaptive real-time video analysis
Subsampling graduates frame analysis duration
23
Table for adaptive scheduling
Frame Analysis length Dy 16 15211 1 1 1 18 7373 1 2 1 / 2 (no data) 1 3 1 / 3 (no data) 2 2 1 / 4 (no data) 2 3 1 / 6 Dx Quality (1/dxdy)
display accuracy / jitter (controlled variable)
24
Strategist: adaptation tactic
CPU / Hardware
Reflective sched. + TDE
Application strategist
executes observes & manipulates OS Kernel
handle_parse() { .... newa = plan_display (when, when + DISPLAY_LEN))) now = lltimer_now_usec(clock); // refresh 'now' avail_time = when - now; // avail.time for analysis if ((avail_time > 0) && ( lookup (adapt_table,ADAPT_TABLE_SIZE,avail_time,&dx,&dy)) ) { // sets analysis quality in dx/dy, // based on the available time newa = plan_analyze (now, now + ANALYZE_LEN); } handle_analyse() { update_adaptive_table (adaptive_table, a->actual.end.usec - a->actual.start.usec, dx, dy, a->frameno); }
adapt_table 10 15211 12 7373 35 n/a
25
Experimental results
- [ Feedback calibration: source code + graph ]
26
Adaptive tuning of display instant
CPU / Hardware
Reflective sched. + TDE
Application strategist
executes observes & manipulates OS Kernel
handle_display (struct Action * a) { error = a->actual.start.raw.raw32 – a- >planned.start.raw.raw32; newcal = - (error) / 2 + oldcal; // feedback correction lltimer_set_calibration (clock, newcal); }
27
Experimental results
28
Thanks
29
References
[OSPERT07] Kevin Elphinstone, David Greenaway and Sergio Ruocco, Lazy Scheduling and Direct Process Switch - Merit or Myths?, Proc. of the 2007 Workshop on Operating Systems Platforms for Embedded Real-Time applications, Pisa, Italy, July 2007. [RTSS06] Sergio Ruocco, User-Level Fine-Grained Adaptive Real-Time Scheduling via Temporal Reflection, Proceedings of 27th IEEE Real-time Systems Symposium, Rio de Janeiro, Brazil, Dec 2006. [OSPERT06] Sergio Ruocco, Real-time Programming and L4 Microkernels, Proc.
- f 2006 Workshop on Operating Systems Platforms for Embedded Real-