TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... ·...

41
Undergraduate course on Real-time Systems Linköping University TDDD07 – Real-time Systems Lecture 1: Course overview & Scheduling I Simin Nadjm-Tehrani Real-time Systems Laboratory Department of Computer and Information Science Linköping University 41 pages Autumn 2019

Transcript of TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... ·...

Page 1: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

TDDD07 – Real-time Systems

Lecture 1:

Course overview & Scheduling I

Simin Nadjm-TehraniReal-time Systems Laboratory

Department of Computer and Information ScienceLinköping University

41 pagesAutumn 2019

Page 2: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

2 of 41 Autumn 2019

Welcome!

• … to this course for computer science and engineering related programs and Master profiles taken by other programs

• Who are this year’s participants?

Page 3: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

3 of 41 Autumn 2019

Updated information

• www.ida.liu.se/~TDDD07– Tell us if you miss something!– Lecture slides from last year will be renewed

one day before the actual lecture• Check timetable/messages for potential

changes in schedule!• Your other contacts:

– Course assistant: Klervie Toczé– Lab assistants: Klervie Toczé, and Rodrigo

Moraes

Page 4: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

4 of 41 Autumn 2019

Examination

• Written exam (4hp)– Bonus points on exam, given in advance for doing

deeper exercises– Lookout for $B sign in lectures!

• Laboratory exercises (2hp)– Nominal amount of work: ~55h of which ~30h on

preparation & programming (for which 12h assistant help is available)

– (pairwise) lab report forms part of examination – Also demonstration & individual oral discussion with

lab assistant

Page 5: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

5 of 41 Autumn 2019

Lab organisation

• Follow the instructions on the web for registration in webreg and forming the lab groups– Deadline: 6th Nov!

• Please read the lab material and prepare before the labs!– You will get access to the lab environment

once you have answered the preparatory questions for the lab

• Students from earlier years?– Please do not register for labs!

Page 6: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

6 of 41 Autumn 2019

Finishing on time

• Check the deadline for lab examination on the course web page!

• Further assistance in 2020 will have to be individually organised (subject to assistant availability)

• For labs not demonstrated before the course deadline two new dates will be announced in April/August

Page 7: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

7 of 41 Autumn 2019

Evaluations earlier years

• “Labs are too easy”• “Labs were a bit unclear as in what we

are supposed to do and how to do it”

– We have had both types of comments before

– Which is why we have a minimum requirement (two first labs) and an additional one for those who found the first two less of a challenge (lab 3, $B)

– We target problem solving in a “real” case

Page 8: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

8 of 41 Autumn 2019

Evaluations earlier years

• “Difficult to read so much”– Part of the course goals is to be able to

extract information from various sources and read research articles

– For Swedish students this is actually part of the educational goals!

HSV: För civilingenjörsexamen skall studenten visa kunskap om det valda teknikområdets vetenskapliga grund och beprövade erfarenhet samt insikt i aktuellt forsknings- och utvecklingsarbete

Page 9: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

9 of 41 Autumn 2019

Questions?

Page 10: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

10 of 41 Autumn 2019

Course overview

• Three lectures on CPU scheduling• Three lectures on distributed

(networked) systems and associated resource/timing aspects

• Three lectures on dependability concepts and predictability in applications

• Final lecture: tying it all together

Page 11: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

11 of 41 Autumn 2019

The first three lectures

• CPU as a resource: Scheduling

This lecture– Introduction to Real-time systems and

why dependability matters

– We start with cyclic scheduling

Page 12: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

12 of 41 Autumn 2019

What is a real-time system?

• Systems that have explicit timing requirements

• Typical examples– Traffic signal in a railway crossing– Alarm monitoring in chemical process

plants: deviations in liquid levels, etc

Page 13: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

13 of 41 Autumn 2019

Fast is not = critical

Source: Assurance of multicore processors in airborne systems,

DOT/FAA/TC-16/51, July 2017

Page 14: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

14 of 41 Autumn 2019

Business: 2 August 2012

• ”An algorithmic trading software bug is being blamed for a day of wild swings at the NYSE –and has resulted in the trader (Knight Capital) placing the dodgy orders that resulted in a $US440 million pre-tax loss for the company.”

• Reuters suggests that timing may have been the problem: the orders may have been intended to be filled during the trading day, but instead were filed in the opening minutes of trading

Page 15: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

15 of 41 Autumn 2019

Novel uses of “real-time”

• Georgia Tech: Crowdsourcing Democracy– A social media aggregator that pulls

content from 20 sources and analyzes the data in real-time using keywords

– Used the tool during Nigeria's presidential election April 2011, tracking the election process

– Identifying problems by monitoring citizen's comments on social media platforms

– Tracked about 50 reports a second, analyzed based on keywords and location data

Page 16: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

16 of 41 Autumn 2019

Early crowdsourcing

• Cambridge University TIME project:create a minute-by-minute image of congestion in cities

• Now in Singapore

• Carnegie Mellon University:

An iPhone application that uses crowdsourcing to enable riders to know when the next bus will arrive

DOI: 10.1109/ICDCS.2015.11

Page 17: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

17 of 41 Autumn 2019

Detecting outbreaks

• Using twitter feeds and machine learning to provide early warning of outbreaks of contagious diseases

Serban et al. May 2019:https://doi.org/10.1016/j.ipm.2018.04.011

Page 18: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

18 of 41 Autumn 2019

Difference

• … with cars and airplanes?

• There is no physical system to control, but the system output is intended to be produced in some temporal relation to system inputs

Page 19: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

19 of 41 Autumn 2019

Inputs can be unpredictable

• ... and requirements are typically fuzzy

• Customer requirements: System is expected to generate the output “in time” even if we can not restrict the rate of arrival of inputs

• Other criteria:–Volume: System must cope with high loads–Freshness: Only recent data useful,

Collected data needs to be time-stamped

Misconception!

Page 20: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

20 of 41 Autumn 2019

Event sequence analysis

Affected 50 million people“A valuable lesson from the ... blackout is the importance of having time-synchronized system data recorders. The Task Force’s investigators labored over thousands of data items to determine the sequence of events much like putting together small pieces of a very large puzzle. That process would have been significantly faster and easier if there had been wider use of synchronized data recording services.”https://www.nerc.com/docs/docs/blackout/NERC_Final_Blackout_Report_07_13_04.pdf

Page 21: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

21 of 41 Autumn 2019

Sending of fire alarms

• When the connection between the alarm systems at South Sweden hospitals and the SoS Larm does not work for 4 hours...

http://www.dn.se/nyheter/sverige/omfattande-larmstrul-i-sodra-sverige/

• Need to study systems that are geographically distributed, need to consider faults

Page 22: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

22 of 41 Autumn 2019

Growing dependence on IoT

• Now affecting pets’ lives

https://www.theguardian.com/technology/2016/jul/27/petnet-auto-feeder-glitch-google

• Where else can things go wrong?

Page 23: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

23 of 41 Autumn 2019

Real-time processes

• From your operating systems course: scheduler’s role is to ensure that each process gets a share of the CPU

• With processes that have harddeadlines it is not enough that processes get a share some time

Hard real-time systems: The time that the result of the computation is delivered is as important as the result itself

• Predictability!

Page 24: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

24 of 41 Autumn 2019

Predictable not = “fast”!

The film...

Page 25: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

25 of 41 Autumn 2019

External event

Computation time

time

Release time Deadline

What is meant by predictable?

Hard real-time systems: Do all processes

meet all their deadlines?

Reaction

D

Page 26: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

26 of 41 Autumn 2019

Deadlines

• Hard: Not meeting any deadline is a failure of the system

• Soft: It is desirable that deadlines are met, but OK if they are missed every now and then

• Firm: It is OK that they are missed now and again, but after the deadline the result is of no use

How often?

Page 27: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

27 of 41 Autumn 2019

Consider following processes:

Computation time (Ci) 5 ms 10 msDeadline (Di) 20 ms 12 ms

p1 p2

p2 timep1t0

timep1p2t0

Order matters!

Page 28: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

28 of 41 Autumn 2019

Scheduling

... is about allocating resources, specially the CPU time, among all computational processes such that the timeliness requirements are met.

If all processes meet their deadlinesthen the process set is schedulable.

Page 29: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

29 of 41 Autumn 2019

The first three lectures

• Introduction to Real-time systems • CPU as a resource: Scheduling

This lecture: – We start with cyclic scheduling

Page 30: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

30 of 41 Autumn 2019

Scheduling

• Performed off-line or on-line • With information available statically or

dynamically• Preemptive or non-preemptive

Page 31: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

31 of 41 Autumn 2019

Which parameters?

Scheduling policy induces an order on executions given an algorithm and a set of parameters for the task set:

• Deadline• Release time• Worst case execution time (WCET)• ...

Page 32: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

32 of 41 Autumn 2019

Process parameters

• How to determine deadlines?• When (how often) is a process released?• How to find the maximum computation

time (WCET) for each process?

Page 33: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

33 of 41 Autumn 2019

Release time

External event

Computation time

Reaction

time

Deadline

Recall: parameters

Deadlines are part of application requirements

D

Page 34: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

34 of 41 Autumn 2019

Release times

• Reading and reacting to continuous signals – Periodicity

• Recognising/reacting to some aperiodicevents – Minimum inter-arrival time Sporadic processes

Page 35: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

35 of 41 Autumn 2019

Computation time (WCET)

• Depends on–Hardware–Application code (algorithm)–Compiler–Data

Page 36: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

36 of 41 Autumn 2019

Cyclic scheduling

• A schedule is created based on statically known and fixed parameters

• Off-line decision on which task runs & when it runs– When executing: Run the processes in pre-

determined order using a table look-up• To run processes in the “right”

frequency find – Minor cycle– Major cycle

Page 37: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

37 of 41 Autumn 2019

Consider following processes: P1 P2

Period(Ti)/Deadline 50 100Worst case execution time (Ci) 10 30

0 100 150 200 250

Note: repetition!

...

50 time

Example (1)

Page 38: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

38 of 41 Autumn 2019

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;}

End of minor cycle

End of minor cycle

Page 39: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

39 of 41 Autumn 2019

First try:Minor cycle: greatest common divisor (sv. sgd)

Major cycle: least common multiplier (sv. mgn)

Example (2):process A B Cperiod 20 40 60

...0 12020

Finding Minor/Major Cycle

Page 40: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

40 of 41 Autumn 2019

Construction of cyclic schedule

Off-line analysis in order to fix the schedule might be iterative

• Each process Pi is run periodically every Ti (i.e. should be completed once every Ti)

• Processes are placed in minor cycle and major cycle until repetition appears

• Check: Are all process instances runnable with the given periods and estimated WCET?

• If not, reconsider the minor/major cycle and/or some process parameters

Page 41: TDDD07 – Real-time Systems Lecture 1: Course overview & …simna73/teaching/REAP/HT19/TDDD... · 2019-11-04 · • Georgia Tech: Crowdsourcing Democracy – A social media aggregator

Undergraduate course on Real-time SystemsLinköping University

41 of 41 Autumn 2019

Next lecture …

• We will continue with a more detailed look at construction of cyclic schedules.