Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Real-time Software Design IS301.

Similar presentations


Presentation on theme: "1 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Real-time Software Design IS301."— Presentation transcript:

1 1 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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:

2 2 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 3 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Topics Introduction to R-T Systems Systems Design Real-Time Executives Monitoring and Control Systems Data Acquisition Systems

4 4 Note content copyright © 2004 Ian Sommerville. NU-specific content 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

5 5 Note content copyright © 2004 Ian Sommerville. NU-specific content 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

6 6 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

7 7 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 8 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Real-Time System Model

9 9 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 10 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Sensor/Actuator Processes

11 11 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 12 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Topics Introduction to R-T Systems Systems Design Real-Time Executives Monitoring and Control Systems Data Acquisition Systems

13 13 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 14 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Hardware and Software Design

15 15 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 16 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 17 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 18 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 19 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 20 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Microwave Oven State Machine (As Shown Before)

21 21 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Petrol pump State Model

22 22 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

23 23 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Java as Real-Time Language Java Supports lightweight concurrency threads and synchronized methods Can be used for some soft real-time systems

24 24 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 25 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Topics Introduction to R-T Systems Systems Design Real-Time Executives Monitoring and Control Systems Data Acquisition Systems

26 26 Note content copyright © 2004 Ian Sommerville. NU-specific content 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

27 27 Note content copyright © 2004 Ian Sommerville. NU-specific content 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

28 28 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

29 29 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Real-Time Executive Components

30 30 Note content copyright © 2004 Ian Sommerville. NU-specific content 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

31 31 Note content copyright © 2004 Ian Sommerville. NU-specific content 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

32 32 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

33 33 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. RTE Process Management

34 34 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 35 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 36 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Topics Introduction to R-T Systems Systems Design Real-Time Executives Monitoring and Control Systems Data Acquisition Systems

37 37 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

38 38 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Generic architecture

39 39 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 40 Note content copyright © 2004 Ian Sommerville. NU-specific content 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

41 41 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

42 42 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

43 43 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Timing Requirements

44 44 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Process Architecture 50 2/sec

45 45 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 46 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Temperature Control System

47 47 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Topics Introduction to R-T Systems Systems Design Real-Time Executives Monitoring and Control Systems Data Acquisition Systems

48 48 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

49 49 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Data acquisition architecture

50 50 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

51 51 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Reactor Flux Monitoring

52 52 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Ring Buffer

53 53 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

54 54 Note content copyright © 2004 Ian Sommerville. NU-specific content 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.

55 55 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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 56 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. 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

57 57 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. DISCUSSION

58 58 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved.

59 59 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved.

60 60 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved.

61 61 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved.

62 62 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved.

63 63 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved.

64 64 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved.


Download ppt "1 Note content copyright © 2004 Ian Sommerville. NU-specific content copyright © 2004 M. E. Kabay. All rights reserved. Real-time Software Design IS301."

Similar presentations


Ads by Google