Introduction to Realtime Systems Chapter 1 R Williams

  • Slides: 18
Download presentation
Introduction to Realtime Systems Chapter 1 R. Williams’ text B. Ramamurthy 9/11/2021 1

Introduction to Realtime Systems Chapter 1 R. Williams’ text B. Ramamurthy 9/11/2021 1

Overview n Realtime processing requires both parallel activities and quick n n n response

Overview n Realtime processing requires both parallel activities and quick n n n response (See figure in p. 2 of a juggler) Design for complexity management. (See figure in p. 3) Microprocessors and realtime applications Definition of realtime systems Programming structures Response latency Relative speeds Timing issues Debugging real-time systems Input/output handling Deadlines (hard, firm and soft) Software quality assurance 9/11/2021 2

Design for complexity management n Choices: n Structured analysis/structured design (SA/SD) n Concurrent design

Design for complexity management n Choices: n Structured analysis/structured design (SA/SD) n Concurrent design approach for real-time systems (CODARTS) n Finite state machines (FSM) n Object-oriented design (OOD) 9/11/2021 3

Lets Design a RT Game n Use two dies; n If the shooter's come-out

Lets Design a RT Game n Use two dies; n If the shooter's come-out roll is a 2, 3 or 12, it is called "craps" and the round ends with player losing. n A come-out roll of 7 or 11 is called a "natural, " resulting in a win. n If the numbers 4, 5, 6, 8, 9, or 10 are rolled on the come-out, this number becomes the "point" and the come out roll is now over. n The shooter will now continue rolling until either the point is rolled or a seven. n n 9/11/2021 If the shooter is successful in rolling the point, the result is a win. If the shooter rolls a seven (called a "seven-out"), the pass line loses. 4

Microprocessor n Examples: vending machines, mobiles phones, alarm systems, washing machines, motor car engine

Microprocessor n Examples: vending machines, mobiles phones, alarm systems, washing machines, motor car engine controllers, heart monitors, microwave ovens all operate using embedded microcontrollers running dedicated software. n Microprocessors are the enabling hardware for realtime systems. 9/11/2021 5

Lets define realtime (RT) systems n Timing: RT systems (RTS) are required to compute

Lets define realtime (RT) systems n Timing: RT systems (RTS) are required to compute and deliver correct results within a specified period of time. Ex: traffic light controller n Interrupt driven: event-driven preemption; RTS are often involved with handling events. n 9/11/2021 Events manifest themselves in terms of interrupt signals arising from the arrival data at an input port or ticking of a hardware clock, or an error status alarm. 6

RTS Definition (contd. ) n Low-level programming: RTS often deal with devices; C language

RTS Definition (contd. ) n Low-level programming: RTS often deal with devices; C language is still a favorite for writing device drivers for new hardware. n Specialized hardware: Most RTS work within, or at least close beside, specialized electronic and mechanical devices. Often closed loop systems. (See fig on p. 6) n Volatile data IO: Variables that change their value from moment to moment. RTS software must be structured to check for changes at the correct rate, so as not to miss a data update. 9/11/2021 7

RTS Definition (contd. ) n Multi-tasking: RTS are often multitasking. Several processes cooperate to

RTS Definition (contd. ) n Multi-tasking: RTS are often multitasking. Several processes cooperate to carry out the overall job. Divide RTS problem into tasks as a design strategy. n Run-time scheduling: Separation of activities into tasks leads to question of task sequencing or scheduling. Moreover the external events and required response to these lead to run-time scheduling or dynamic scheduling. n Unpredictability: Being event-driven, RTS are at the mercy of unpredictable changes in their environment. n Life-critical code: failure to run correctly may result in death or at least injury to the user and/or others. Lifecritical systems requires extra testing, documentation and acceptance trials. 9/11/2021 8

Programming Structures n Also known as control structures n Sequence (SEQ) n Iteration (IT)

Programming Structures n Also known as control structures n Sequence (SEQ) n Iteration (IT) n Branches guarded by selection statements (SEL) n Parallel or concurrent instructions (PAR) n Critical group of exclusive instructions (CRIT) 9/11/2021 9

Relative Speeds n Polling is a common method used in RTS for sensing events/inputs.

Relative Speeds n Polling is a common method used in RTS for sensing events/inputs. n When designing RTS Avoid polling input too slowly, you may miss events n Avoid sampling to frequently (called aliasing), since it will make the process inefficient. n Nyquist limit: The maximum frequency threshold is half the sampling rate referred to as Nyquist limit. n 9/11/2021 10

V 2 F: Voltage to Frequency n A commonly used environmental monitoring n n

V 2 F: Voltage to Frequency n A commonly used environmental monitoring n n arrangement involves a transducer being interfaced to a voltage-frequency converter. V 2 F unit converts voltage to frequency: larger voltage, higher frequency; lower voltage, lower frequency. Computer has to dedicate a single bit input port to accept the information in serial mode. Problem: converting this bit information into integer. Timing of the two branches in the following sequences are not balanced; run these two alternatingly. 9/11/2021 11

Software Timing loop for 100 msec { if (input_bit) hcount++; else lcount++; } 9/11/2021

Software Timing loop for 100 msec { if (input_bit) hcount++; else lcount++; } 9/11/2021 loop for 100 msec { if (!input_bit) lcount++; else hcount++; } 12

High Speed Timing n Consider a laser range finder used in civil surveying, and

High Speed Timing n Consider a laser range finder used in civil surveying, and battle n n n n field targeting. Distance is calculated by the timing the duration of flight. The Speed of light: s= 3 X 108 m/sec Target is 20 km away, the pulse of light will travel 40 km (to and from): d = 4 X 104 m Time taken: d/s = 4 X 104 / 3 X 108 = 130μs If the item surveys is only at 150 m distance, the flight time will be reduced to 325 ns. Regular 500 MHz computer will not do for this. Solution: Clear a high speed counter when the pulse leaves and capture the counter value on return of the pulse. Assignment: Research and explain how this is done in a golf distance finder. 9/11/2021 13

Output timing n Timing problems when controlling output devices such as motors. n Cyclic,

Output timing n Timing problems when controlling output devices such as motors. n Cyclic, periodic output data. n Several types of motors: stepper, DC servo, universal AC, induction AC, synchronous AC etc. n For example sometimes we need to dispatch every 20 ms with an accuracy of 50μs. n Solution: need special hardware support: controller boards. 9/11/2021 14

Machine IO n Programmed IO n Interrupt driven n Direct memory access 9/11/2021 15

Machine IO n Programmed IO n Interrupt driven n Direct memory access 9/11/2021 15

Types of RTS n Hard RTS: tight limits on response time, so that a

Types of RTS n Hard RTS: tight limits on response time, so that a delayed result is a wrong result. n Ex: jet fuel controller and camera shutter unit n Soft RTS: need to meet only time-average performance target. As long as most results are available before deadline the system will run successfully. n Ex: audio and video transmission, single frame skip is fie, but repeated loss is unacceptable n Firm RTS: somewhere between the two. n Ex: Space station solar panel unit 9/11/2021 16

Software Quality Assurance n QA is especially important to RTS since many of these

Software Quality Assurance n QA is especially important to RTS since many of these are deployed in life critical environments / situations. n Patriot missile failure n Therac-25 accident 9/11/2021 17

Summary n We studies key issues which make development of realtime software more challenging

Summary n We studies key issues which make development of realtime software more challenging than desktop or traditional data processing applications. n Timing is very critical for RTS input, output, computing and response. n See the timing units of measurement on page 26. n Read the reference papers 9/11/2021 18