Presentation is loading. Please wait.

Presentation is loading. Please wait.

Real-time Software Design

Similar presentations


Presentation on theme: "Real-time Software Design"— Presentation transcript:

1 Real-time Software Design
IS301 – Software Engineering Lecture # 19 – M. E. Kabay, PhD, CISSP Assoc. Prof. Information Assurance Division of Business & Management, Norwich University V: M. E. Kabay, PhD, CISSP Copyright © 2004 M. E. Kabay All rights reserved.

2 Objectives To explain the concept of a real-time system and why these systems are usually implemented as concurrent processes To describe a design process for real-time systems To explain the role of a real-time operating system To introduce generic process architectures for monitoring and control and data acquisition systems

3 Topics Introduction to R-T Systems Systems Design Real-Time Executives
Monitoring and Control Systems Data Acquisition Systems

4 Copyright © 2004 M. E. Kabay. All rights reserved.
Real-Time Systems Systems which monitor and control their environment Inevitably associated with hardware devices Sensors: Collect data from system environment Actuators: Change (in some way) system's environment Time critical. Real-time systems MUST respond within specified times Copyright © 2004 M. E. Kabay All rights reserved.

5 Copyright © 2004 M. E. Kabay. All rights reserved.
Definition Real-time system: Correct functioning of system depends on results produced by system and time at which these results produced ‘Soft’ real-time system: Operation degraded if results not produced according to specified timing requirements ‘Hard’ real-time system Operation incorrect if results not produced according to timing specification Copyright © 2004 M. E. Kabay All rights reserved.

6 Stimulus/Response Systems
Given stimulus, system must produce response within specified time Periodic stimuli Occur at predictable time intervals E.g., T° sensor polled 10 times/second Aperiodic stimuli Occur unpredictably E.g., system power failure Copyright © 2004 M. E. Kabay All rights reserved.

7 Architectural Considerations
Allow fast switching between stimulus handlers Different stimuli have different timing demands E.g., weather station – T° vs light intensity Thus simple sequential loop not usually adequate Real-time systems Usually designed as cooperating processes With real-time executive controlling these processes

8 Real-Time System Model
Copyright © 2004 M. E. Kabay All rights reserved.

9 System Elements Sensors control processes
Collect information from sensors. May buffer data Data processor Carries out processing of collected information Computes system response Actuator control Generates control signals for actuator

10 Sensor/Actuator Processes
Copyright © 2004 M. E. Kabay All rights reserved.

11 System Elements Sensor control processes
Collect information from sensors. May buffer information collected in response to a sensor stimulus. Data processor Carries out processing of collected information and computes the system response. Actuator control processes Generates control signals for the actuators.

12 Topics Introduction to R-T Systems Systems Design Real-Time Executives
Monitoring and Control Systems Data Acquisition Systems

13 System Design Design both hardware and software associated with system
Partition functions to either hardware or software Design decisions should be made on basis on non-functional system requirements Hardware delivers better performance But potentially longer development Less scope for change

14 Hardware and Software Design

15 R-T Systems Design Process (1)
Identify stimuli to be processed Required responses to these stimuli For each stimulus and response, Identify timing constraints Aggregate stimulus and response processing into concurrent processes Process may be associated with each class of stimulus and response

16 R-T systems Design Process (2)
Design algorithms to process each class of stimulus and response. Meet given timing requirements Design scheduling system Ensure processes started in time to meet deadlines (during execution) Integrate using real-time executive or operating system

17 Timing Constraints Difficult to predict
Extensive simulation and experiment to ensure that these met by system May mean that certain design strategies such as object-oriented design cannot be used Too much overhead involved May mean that low-level programming language features have to be used For performance reasons

18 State Machine Modeling
Effect of stimulus in real-time system may trigger transition from one state to another. Finite state machines (FSM) can be used for modeling real-time systems However, FSM models lack structure. Even simple systems can have complex model. UML includes notations for defining state machine models See also Chapter 7

19 State Machine Modeling
Effect of stimulus in real-time system may trigger transition from one state to another. Finite state machines can be used for modeling real-time systems. However, FSM models lack structure. Even simple systems can have complex model. UML includes notations for defining state machine models See also Chapter 7.

20 Microwave Oven State Machine (As Shown Before)
Copyright © 2004 M. E. Kabay All rights reserved.

21 Petrol pump State Model
Copyright © 2004 M. E. Kabay All rights reserved.

22 Real-Time Programming
Hard real-time systems Often in assembly language to ensure that timing requirements met High-level languages such as C Allow efficient programs to be written But do not have constructs to support concurrency or shared resource management Ada Designed to support real-time systems design Includes general purpose concurrency mechanism Copyright © 2004 M. E. Kabay All rights reserved.

23 Java as Real-Time Language
Supports lightweight concurrency threads and synchronized methods Can be used for some soft real-time systems

24 Java (2) Java 2.0 not suitable for hard RT programming or programming where precise control of timing required Not possible to specify thread execution time Uncontrollable garbage collection Not possible to discover queue sizes for shared resources Variable virtual machine implementation Not possible to do space or timing analysis

25 Topics Introduction to R-T Systems Systems Design Real-Time Executives
Monitoring and Control Systems Data Acquisition Systems

26 Copyright © 2004 M. E. Kabay. All rights reserved.
Real-Time Executives Real-time executives Specialized operating systems Manage processes in RTS Standard RTE kernel Used as-is; or Can be modified for particular application Limited No file management facilities 14 Copyright © 2004 M. E. Kabay All rights reserved.

27 Copyright © 2004 M. E. Kabay. All rights reserved.
Executive Components Real-time clock Info for process scheduling Interrupt handler Manages aperiodic requests for service. Scheduler Chooses next process to be run Resource manager Allocates memory and processor resources Dispatcher Starts process execution Copyright © 2004 M. E. Kabay All rights reserved.

28 Non-Stop System Components
Configuration manager Dynamic reconfiguration of system SW, HW without stopping systems Replace HW modules Upgrade SW Fault manager Detect SW & HW faults Take appropriate actions E.g. switch to backup disks Ensure that system continues operation Copyright © 2004 M. E. Kabay All rights reserved.

29 Real-Time Executive Components
Copyright © 2004 M. E. Kabay All rights reserved.

30 Copyright © 2004 M. E. Kabay. All rights reserved.
Process Priority Processing some types of stimuli must sometimes take priority Interrupt level priority Highest priority allocated to processes requiring very fast response Clock level priority Allocated to periodic processes Further levels of priority may be assigned within these levels Copyright © 2004 M. E. Kabay All rights reserved.

31 Copyright © 2004 M. E. Kabay. All rights reserved.
Interrupt Servicing Control transferred automatically to pre-determined memory location Contains instruction to jump to interrupt service routine Further interrupts disabled, Interrupt serviced Control returned to interrupted process Interrupt service routines MUST be short, simple and fast Copyright © 2004 M. E. Kabay All rights reserved.

32 Periodic Process Servicing
Several classes of periodic process Different periods (time between executions) Different execution times Different deadlines (time by which processing must be completed) Real-time clock ticks periodically Each tick causes interrupt which schedules process manager for periodic processes Process manager selects process among those ready for execution Copyright © 2004 M. E. Kabay All rights reserved.

33 RTE Process Management
Copyright © 2004 M. E. Kabay All rights reserved.

34 Process Switching Scheduler
Chooses next process to be executed by processor Depends on scheduling strategy May take process priority into account Resource manager Allocates memory and processor Dispatcher Takes process from ready list, Loads it onto processor Starts execution

35 Scheduling Strategies
Non pre-emptive scheduling Process runs to completion Or until blocked (e.g. pending I/O) Pre-emptive scheduling Execution of executing processes may be stopped If higher-priority process requires service Scheduling algorithms Round-robin Rate monotonic Shortest deadline first

36 Topics Introduction to R-T Systems Systems Design Real-Time Executives
Monitoring and Control Systems Data Acquisition Systems

37 Monitoring and Control Systems
Important class of real-time systems Continuously check sensors and take actions depending on sensor values Monitoring systems examine sensors and report their results Control systems take sensor values and control hardware actuators Copyright © 2004 M. E. Kabay All rights reserved.

38 Copyright © 2004 M. E. Kabay. All rights reserved.
Generic architecture Copyright © 2004 M. E. Kabay All rights reserved.

39 Burglar Alarm System Monitor sensors on doors and windows
Detect presence of intruders in building When sensor indicates break-in Switches on lights around area Calls police automatically Provision for operation even when external power fails / cut

40 Copyright © 2004 M. E. Kabay. All rights reserved.
Burglar Alarm System Sensors Movement detectors, window sensors, door sensors. 50 window sensors, 30 door sensors and 200 movement detectors Voltage-drop sensor Actions When intruder detected, police called automatically Lights switched on in rooms with active sensors Audible alarm switched on System switches automatically to backup power when voltage drop detected Copyright © 2004 M. E. Kabay All rights reserved.

41 R-T System Design Process
Identify stimuli and associated responses Define timing constraints associated with each stimulus and response Allocate system functions to concurrent processes Design algorithms for stimulus processing and response generation Design scheduling system which ensures that processes will always be scheduled to meet their deadlines Copyright © 2004 M. E. Kabay All rights reserved.

42 Stimuli To Be Processed
Power failure Generated aperiodically by circuit monitor Switch to backup power within 50 ms Intruder alarm Stimulus generated by system sensors Response Call police Switch on building lights Audible alarm Copyright © 2004 M. E. Kabay All rights reserved.

43 Timing Requirements

44 Copyright © 2004 M. E. Kabay. All rights reserved.
50 2/sec Process Architecture Copyright © 2004 M. E. Kabay All rights reserved.

45 Control Systems Burglar alarm system Primarily monitoring
Collects data from sensors No real-time actuator control Control systems System sends control signals to actuators E.g., temperature-control system Monitors T° Switches heaters on and off

46 Temperature Control System
Copyright © 2004 M. E. Kabay All rights reserved.

47 Topics Introduction to R-T Systems Systems Design Real-Time Executives
Monitoring and Control Systems Data Acquisition Systems

48 Data Acquisition Systems
Collect data from sensors for subsequent processing and analysis. Data collection processes and processing processes may have different periods and deadlines Data collection may be faster than processing E.g. collecting information about explosion Circular or ring buffers Mechanism for smoothing speed differences File where new data added at bottom displace old data at top Copyright © 2004 M. E. Kabay All rights reserved.

49 Data acquisition architecture

50 Reactor Data Collection
System collects data Sensors monitoring neutron flux From nuclear reactor Flux data placed in ring buffer For later processing Ring buffer Implemented as concurrent process Collection and processing processes may be synchronized Size of buffer must be set to account for discrepancy of filling (sensors) and emptying (processing) speeds Copyright © 2004 M. E. Kabay All rights reserved.

51 Reactor Flux Monitoring
Copyright © 2004 M. E. Kabay All rights reserved.

52 Ring Buffer

53 Mutual Exclusion (Locking)
Producer processes collect data and add it to buffer Consumer processes take data from buffer and make elements available Producer and consumer processes must be mutually excluded from accessing same element Buffer must stop producer processes adding information to full buffer and consumer processes trying to take information from empty buffer Copyright © 2004 M. E. Kabay All rights reserved.

54 Copyright © 2004 M. E. Kabay. All rights reserved.
Key points Real-time system correctness depends not just on what the system does but also on how fast it reacts. A general RT system model involves associating processes with sensors and actuators. Real-time systems architectures are usually designed as a number of concurrent processes. Copyright © 2004 M. E. Kabay All rights reserved.

55 Key points Real-time operating systems are responsible for process and resource management. Monitoring and control systems poll sensors and send control signal to actuators. Data acquisition systems are usually organized according to a producer consumer model.

56 Homework Required By Wed 20 Oct 2004 For 35 points,
Optional By Wed 27 Oct 2004 For a maximum of 15 points, answer either or both of 15.4 15.10

57 Copyright © 2004 M. E. Kabay. All rights reserved.
DISCUSSION Copyright © 2004 M. E. Kabay All rights reserved.

58

59

60

61

62

63

64


Download ppt "Real-time Software Design"

Similar presentations


Ads by Google