Process as an abstraction TDDB47 – Real-time Systems Lecture 1: Introduction Simin Nadjm-Tehrani Real-time Systems Laboratory Department of Computer and Information Science Linköping university Undergraduate course on Real-time Systems Linköping 40 pages Autumn 2005 To model: • Management of different computational processes by operating systems • Parallel developments within the physical environment as well as the control system • Nodes in a network, with interaction and communication Undergraduate course on Real-time Systems Linköping An example Performance criteria • For operating systems it is enough to show that processes will not end up in deadlock or livelock • With real-time systems it is not enough that the system eventually responds 2 of 40 Autumn 2005 The film… The time that the result of the computation is delivered is as important as the result itself • Predictability! Undergraduate course on Real-time Systems Linköping 3 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping What is meant by predictable? Release time Computation time Deadline time Event Reaction 4 of 40 Autumn 2005 Hard real-time • If the sensor detects a crash, the air bag in the car should be activated within a given time • If the signal is red, the train must be stopped within a given time • If the liquid level has reached the max. value, the valve must be opened within a given time Hard real-time: All processes meet their deadline! Undergraduate course on Real-time Systems Linköping 5 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping 6 of 40 Autumn 2005 Deadlines • Hard: Not meeting any deadline is a failure of the system How often? • Soft: It is desirable that deadlines are met, but OK if they are missed now and again • Firm: It is OK that they are missed now and again, but after the deadline the result is of no use Undergraduate course on Real-time Systems Linköping 7 of 40 Autumn 2005 Real-time systems research • Traditionally on hard real-time problems • Most systems consist of subsystems with hard, firm, and soft deadlines • Many exciting applications of today have problems that no longer fit in the framework of traditional hard real-time! Undergraduate course on Real-time Systems Linköping 8 of 40 Autumn 2005 Real-time vs. embedded • Many Real-time computations are embedded in application systems: Embedded systems A computer system that – is part of a larger system – is tailor-made for a specific application – is characterised by restricted programmability by the user – has tight interaction with a physical environment • But there are embedded systems that are not real-time • And Real-time systems that are not embedded Undergraduate course on Real-time Systems Linköping Embedded systems 9 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping 10 of 40 Autumn 2005 Typical application areas • • • • Less obvious ... • Avoiding overload in CPU that runs traffic functions in RNC despite fluctuations in user requests Command and control Transportation Medical devices Multimedia and voice transfer RNC RBS Core Network RBS Load control Cells Undergraduate course on Real-time Systems Linköping 11 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping 12 of 40 Autumn 2005 Lecture topics • One lecture with two novel applications! – Embedded databases in engine control – Bandwidth allocation to differentiated users in a 3G telecom network Sharing the brain Labs based on football playing robots • Computational processes given, parameters given, how to allocate CPU so that a team plays better football? • You will implement three schedulers and compare them Undergraduate course on Real-time Systems Linköping 13 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping 14 of 40 Autumn 2005 Information • Posted on: www.ida.liu.se/~TDDB47 • Your other contacts: – Course assistant: Aleksandra Tesanovic – Lab assistant: Calin Curesu – Course secretary: Anne Moe Now a little on course organisation! Undergraduate course on Real-time Systems Linköping 15 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping Lab organisation 16 of 40 Autumn 2005 Extra lesson • Follow the instructions on the web for registration and forming the lab groups • For DI students, or others with no Java background • Get the compendium, read it, and attend the lab introductory lesson, for a complete preparation before the labs • This year: two sessions that can be taken at different times, covering introductory parts to Java! Undergraduate course on Real-time Systems Linköping 17 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping 18 of 40 Autumn 2005 Important notice • Lab environment is under development • Please make sure that you observe the instructions – for finishing the labs before deadline – and followup examination sessions • By next year the labs may be different! Undergraduate course on Real-time Systems Linköping 19 of 40 Autumn 2005 Readings • The course book is not covered/followed chapter by chapter! • There is additional reading material posted to the web: – Book chapters: get the reference copies – Articles: will be posted Undergraduate course on Real-time Systems Linköping 20 of 40 Autumn 2005 Scheduling ... is about allocating resources, specially the CPU time, among all computational processes such that the timeliness requirements are met. Now back to business! The scheduler decides which process is to be executed next. Undergraduate course on Real-time Systems Linköping 21 of 40 Autumn 2005 Scheduling • Performed off-line or on-line • With information available statically or dynamically • Preemptive or non-preemptive Undergraduate course on Real-time Systems Linköping 23 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping 22 of 40 Autumn 2005 Schedulability Analysis • To confirm that the deadlines for a set of processes can be guaranteed using a given policy • The process set is then considered ”schedulable” Undergraduate course on Real-time Systems Linköping 24 of 40 Autumn 2005 Order matters! Computation time Release time Consider following tasks: Deadline time Computation time (Ci) Deadline (Di) Event Reaction t0 How should we take care of several parallel activities? Undergraduate course on Real-time Systems Linköping t0 25 of 40 Autumn 2005 a1 a2 5 ms 20 ms a2 • • • • Worst case execution time (WCET) Deadline Release time ... Undergraduate course on Real-time Systems Linköping 27 of 40 Autumn 2005 a1 Undergraduate course on Real-time Systems Linköping 29 of 40 Autumn 2005 10 ms 12 ms time Undergraduate course on Real-time Systems Linköping 26 of 40 Autumn 2005 Parameters • How to find the maximum computation time for each process? • How to determine deadlines? • When (how often) is a process released? Undergraduate course on Real-time Systems Linköping Release times • Periodicity: when reading and reacting to continuous signals • Minimum inter-arrival time: when recognising/reacting to some aperiodic events (sporadic processes) a2 time Which parameters? Scheduling policy induces an order on executions using an algorithm and a set of parameters: a1 28 of 40 Autumn 2005 Off-line scheduling ... With a cyclic executive • A static schedule is fixed based on pre-runtime analysis • The analysis might have to be repeated [Iterative check: Will it work with the natural periods and computation times? Otherwise, change the parameters!] • When executing: Run the processes in predetermined order using a table look-up Undergraduate course on Real-time Systems Linköping 30 of 40 Autumn 2005 A cyclic executive every_major_cycle do{ read all in_signals; run_minor_cycle_1_processes; wait_for_interrupt; write all out_signals; ... read all in_signals; run_minor_cycle_n_processes; wait_for_interrupt; write all out_signals; } Example (1) Consider following processes: P1 P2 Period/Deadline(Ti) Worst case execution time (Ci) 50 10 100 30 Note: repetition! ... 0 Undergraduate course on Real-time Systems Linköping 50 100 150 200 Undergraduate course on Real-time Systems Linköping 31 of 40 Autumn 2005 time 250 32 of 40 Autumn 2005 Harmonic processes Minor cycle: greatest common devisor (sv. sgd) What if periods are not harmonic? Major cycle: least common multiplier (sv. mgn) Example: process period A 20 B 40 C 60 ... 0 20 120 Undergraduate course on Real-time Systems Linköping Undergraduate course on Real-time Systems Linköping 33 of 40 Autumn 2005 How to construct? • Each process Pi is assumed to be strictly periodic (i.e. should be run once every Ti) • Place the processes in minor cycle and major cycle until repetition appears • If the periods are not harmonically related – change the periods – all processes should be run at least as often as every (original) Ti Undergraduate course on Real-time Systems Linköping Example (2.1) process period A 75 B 100 Alternative 1: Run process B more often than necessary, e.g. once every 75 time units. minor cycle 0 35 of 40 Autumn 2005 34 of 40 Autumn 2005 75 Undergraduate course on Real-time Systems Linköping Drawbacks? ... time 36 of 40 Autumn 2005 Example (2.2) process period A 75 B 100 Alternative 2: Choose minor cycle as greatest common divisor, and move processes backwards in time when they clash. 100 time 150 Undergraduate course on Real-time Systems Linköping A 75 B 100 Drawbacks? ... 25 process period Alternative 3: A mix of the last two Drawbacks? 0 Example (2.3) 37 of 40 Autumn 2005 Schedulability test • Sum of processes’ execution times (WCET) in each minor cycle is less than the cycle’s length, and processes run at the ”right” frequency. minor cycle 0 ... time 50 Undergraduate course on Real-time Systems Linköping 38 of 40 Autumn 2005 Reading for this lecture • Burn & Wellings, Ch 1. and Ch. 13 If succeeded: • the schedule, whose length corresponds to the major cycle, is repeated for all executions. Undergraduate course on Real-time Systems Linköping 39 of 40 Autumn 2005 Undergraduate course on Real-time Systems Linköping 40 of 40 Autumn 2005