RealTime Systems 70935 - PowerPoint PPT Presentation

1 / 67
About This Presentation
Title:

RealTime Systems 70935

Description:

Generally taken to mean a computer system, substantially a software system ... Processor specific commercial IDEs. Real-Time Concepts. Compiler platforms ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 68
Provided by: mphyt
Category:
Tags: realtime | ides | systems

less

Transcript and Presenter's Notes

Title: RealTime Systems 70935


1
Real-Time Systems70935
  • Mark Phythian

email phythian_at_usq.edu.au location Z435
Faculty of Eng Surveying U.S.Q.
2
Introduction
  • Unit Specification
  • Unit Outline
  • Expectations
  • Background

3
Topics of Study
  • Real-Time Concepts
  • Real-Time Software Design
  • Programming Language for RTS
  • Coding Techniques Algorithms
  • Multitasking
  • Interprocess Communications
  • Process Synchronisation Timing

4
Real-Time Concepts
  • Objectives
  • introduce the concept of a real-time system
  • understand terminology and definitions
  • investigate some real-time system failures
  • introduce the cygwin compiler

5
Real-Time ConceptsWhat is a Real-Time System?
  • Generally taken to mean a computer system,
    substantially a software system
  • A system whose responses must be timely as well
    as correct or risk failure
  • Often thought of as fast systems but this is
    not necessarily the case
  • Performance estimation and determinism are
    crucial in a Real-Time System

6
Real-Time ConceptsWhat is an Operating System?
  • Often mistaken as the users interface to a
    computer system, an Operating System comprises
  • a Resource Manager
  • a Task Manager
  • a Memory Manager
  • a System interface

7
Real-Time Concepts Real-Time Terminology
  • System terms
  • a system is any entity that has inputs and
    outputs
  • a response time is the interval between an input
    change and the corresponding output
  • a set of inputs is considered bounded if they
    always remain within specified limits
  • a system specification is a document defining the
    systems requirements

8
Real-Time Concepts Real-Time Terminology
  • System terms (cont)
  • a real-time system is one which must meet
    specified bounded response time constraints or
    cause a system failure
  • a system failure is the result of failing to
    satisfy one or more specified requirements
  • time loading is a measure of the useful
    processing the computer is doing expressed as a
    percentage of its full capacity

9
Real-Time Concepts Real-Time Terminology
  • System terms (cont)
  • an embedded system - where the software is
    completely encompassed by the hardware system
  • an organic system is one in which the software is
    independent of the hardware
  • a semi-detached system is one in which the
    software may run on alternate hardware with some
    hardware related modifications

10
Real-Time Concepts Real-Time Terminology
  • System terms (cont)
  • a soft real-time system - where performance is
    degraded by missed deadlines but does not cause a
    system failure
  • a hard real-time system - where failure to meet
    response time constraints causes a system failure
  • a firm real-time system - where failure to meet
    response time constraints can be tolerated
    occasionally

11
Real-Time Concepts Real-Time Terminology
  • Event related terms
  • an event is any occurrence which causes a change
    is system state or flow of control
  • a synchronous event is any event which occurs at
    a predictable time in the flow of control
  • an asynchronous event is any event whose
    occurrence can not be predicted
  • a system state is any unique condition that a
    system can attain, as defined by a set of system
    variables

12
Real-Time Concepts Real-Time Terminology
  • Event related terms (cont)
  • a deterministic event is one for which a unique
    set of responses and the next state can be
    determined for each possible state and set of
    inputs
  • event determinism is where a unique set of
    responses and the next state can be determined
    for that event
  • temporal determinism is where the response times
    of the system can be determined for each possible
    state and set of inputs

13
Real-Time ConceptsCompiler platforms
  • C is often the language of choice for Real-Time
    systems designers, and comes in several
    flavours
  • Unix original cc
  • DOS TurboC, Gnu C ... gcc
  • Windows MS VC, cygwin ...
  • Processor specific commercial IDEs

14
Real-Time ConceptsCompiler platforms
  • Freeware C compilers for the PC are available as
    follows -
  • DOS Gnu C DJGPP port
  • ftp//mirror.aarnet.edu.au/pc/simtelnet/gnu/djgpp/
  • Windows Gnu C cygwin port
  • http//mirror.aarnet.edu.au/cygwin/
  • (This is the recommended compiler)

15
Real-Time ConceptsReal-Time System Examples
  • Further information is available on J. Leiss Web
    site at
  • www.usq.edu.au/users/leis/70935/70935.htm
  • Take a look at the following links to well
    documented Real-Time System failures
  • www.around.com/ariane.html
  • courses.cs.vt.edu/cs3604/lib/Therac_25/Therac_1.h
    tml

16
Real Time Software Design
  • Objectives
  • introduce software engineering design
  • describe elements of a R-T system Specification
  • learn to use real time software design tools
  • learn how to implement real-time kernels

17
Real Time Software DesignSoftware Life Cycle
  • The Software Life Cycle / Design Phases
  • Conception
  • Specification
  • Design
  • Programming
  • Testing
  • Maintenance

18
Real Time Software DesignSoftware Life Cycle
  • Conception Phase
  • identify the opportunity / need for a product
  • identify the features / objectives of the product
  • produce market / feasibility studies

The R-T Systems Engineer is often involved in
evaluating and preparing technical aspects of
proposals, estimating potential performance and
practicalities.
19
Real Time Software DesignSoftware Life Cycle
  • Specification Phase
  • identify the functions / requirements of the
    product
  • produce system specification documentation
  • produce schedule, budget and contract documents
  • produce a test plan for system verification

The R-T Systems Engineer is most likely to have
direct input to this phase when the objective is
to produce an enhanced version of an existing
product.
20
Real Time Software DesignSoftware Life Cycle
  • Design Phase
  • partition the functions and processes into
    modules
  • identify potential problems in the systems spec
  • produce the system design documentation
  • produce a set of test cases based on the test plan

The R-T Systems Engineer is likely to be a member
of a team of design engineers for this phase.
21
Real Time Software DesignSoftware Life Cycle
  • Programming Phase
  • decide on a kernel structure and implement it
  • create the data structures and write the modules
  • debug the software
  • develop test cases and procedures
  • integrate modules to form a functional system

For the R-T Systems Engineer it is important to
properly manage the software development process
to ensure quality.
22
Real Time Software DesignSoftware Life Cycle
  • Test Phase
  • verify system function and performance according
    to the test plan
  • perform system stability and performance tests
    under various loading models
  • produce test reports detailing compliance

The R-T Systems Engineer is often involved in
testing and commissioning.
23
Real Time Software DesignSoftware Life Cycle
  • Maintenance Phase
  • deploy the system into practical application
  • provide a customer support system incl. error rep
  • maintain the system through a series of revisions

The R-T Systems Engineer may be involved in this
phase on system enhancements or regression
testing.
24
Real Time Software DesignR-T System
Specification Design
  • Descriptive Techniques
  • Mathematical Techniques
  • Procedural Techniques
  • Structural Techniques
  • State-based Techniques

25
Real Time Software DesignSpecification Design
Techniques
  • Descriptive Techniques
  • natural language (possibly ambiguous)
  • psuedo-code or structured english (an
    improvement)
  • Mathematical Techniques
  • equations (not always practical)
  • defining the statics and dynamics of the system
    (recommended)

26
Real Time Software DesignSpecification Design
Techniques
  • Procedural Techniques
  • flow charts (not suitable for real-time specs)
  • dataflow diagrams (recommended)
  • Structural Techniques
  • structure charts (not represent R-T systems well)
  • Warnier-Orr Notation (recommended)

27
Real Time Software DesignSpecification Design
Techniques
Finite State Machines Defining a system as a
fixed number of unique states between which a
system moves in response to events.
  • State-based Techniques
  • state diagrams (very suitable for R-T design)
  • state charts (recommended)

28
Real Time Software DesignSpecification Design
Techniques
  • There are two types of Finite State Machine

Moore Machines Where the system outputs can only
be defined in terms of the system state variables.
Mealy Machines Where the system outputs can be
defined in terms of both the system state
variables and the system inputs.
29
Programming Languages for Real-Time Systems
  • Objectives
  • identify desirable features of R-T languages
  • identify programming language issues
  • revise the C programming language
  • introduce the cygwin environment
  • introduce some C language features

30
Programming Languages for R-T Systems What are
Language Features?
  • Parameter Passing
  • Recursion
  • Dynamic Allocation
  • Data Typing
  • Exception Handling
  • Interrupt Handling
  • Modularity
  • Abstract Data Types

31
Programming Languages for R-T Systems Desirable
R-T Language Features
  • Versatile parameter passing mechanisms
  • Strong typing
  • Exception handling
  • Interrupt types
  • Modularity

32
Programming Languages for R-T Systems Survey
of Common Languages
  • Basic
  • Fortran
  • C
  • Pascal
  • Modula-2
  • Ada
  • Assembly Language

33
Programming Languages for R-T SystemsThe C
Programming Language
  • GNU C and compiler switches
  • C compilation, linking and execution
  • Include files and file structure
  • Header files, function prototypes and libraries
  • C Program Structure

34
Programming Languages for R-T SystemsC Program
Structure
  • Command line arguments
  • Loading and saving data
  • Data structures
  • Operators
  • Advanced topics
  • portability
  • makefiles

35
Programming Languages for R-T SystemsC
Programming Language
  • C is an object oriented version of C including
    several additions in the language
  • Object Orientation refers to the paradigm of a
    single object defined by both its data and the
    functions which operate on that data.

36
Programming Languages for R-T Systems C
Programming Language
  • Advantages
  • Reliability
  • Reusability
  • Co-ordination
  • Better abstraction
  • Maintainability?
  • Disadvantages
  • Loss of speed
  • Hard to predict
  • More garbage collection
  • Increased complexity

37
Programming Languages for R-T Systems C
Programming Language
  • Some differences to C
  • comments / / and // single line
  • cout ltlt output string and variables
  • Abstract Data Types
  • typedef
  • struct
  • association of data and code

38
Programming Languages for R-T Systems C
Programming Language
  • Object Oriented Principles Concepts
  • it is desirable to bind data and code
  • a class defines both data and associated code
  • data defines characteristics of the class
  • the code is bound to the data for operations
  • essentially a structure with code added
  • as struct is just a prototype so to is a class

39
Programming Languages for R-T Systems C
Programming Language
  • Object Oriented Principles Concepts (cont)
  • an instance of a class is called an object
  • functions within a class are called methods
  • data defined within a class are the attributes of
    the class
  • the concept of data hiding and encapsulation are
    fundamental to the OOP paradigm

40
Programming Languages for R-T Systems C
Programming Language
  • Object Definitions in C
  • the keyword class is used (like struct)
  • data can be declared as private or public
  • as can the methods of the class
  • when an object is created, initialisation is done
    by the class constructor
  • the removal of the object uses the destructor

41
Coding Techniques
  • Objectives
  • introduce error handling techniques
  • discuss assembly language and optimisation
  • linking C and assembly language
  • discuss issues of memory management

42
Coding Techniques Error Handling
  • Real-time systems often involve embedded or
    unsupervised operation so it is important that
  • errors are reported, typically in a log file
  • reports of errors are informative (at least to
    the software design engineer)
  • recovery from errors - where possible - is
    orderly and uniformly handled

43
Coding Techniques Assembly Language
  • Real-time systems often require the inclusion of
    sections of assembly language programming
  • for interfacing low level hardware devices
  • for performing very high speed operations
  • for connecting to some operating system functions

44
Coding Techniques C to Assembly
  • The following points summarise the connection
    between C and assembly code
  • C programs can be compiled into assembly language
    using the -S option with GNU C
  • assembly files (.s) can be linked with C files
    using gcc cfile.c asmfile.s .
  • the base pointer is used for local variable
    referencing on the PC

45
Coding Techniques C calling Assembly
  • The following points summarise the calling
    conventions from C to assembly code
  • function parameters are pushed onto the stack
  • the return address is pushed under the params
  • the base pointer is saved under the return addr
  • local variable space is alocated under the saved
    base pointer
  • local variables are referenced from the BP

46
Coding Techniques Software Optimisations
  • The designer has the ability to significantly
    improve the performance of software by
  • careful ordering of nested test conditions
  • constant folding
  • constant propagation
  • strength reduction
  • dead code removal

47
Coding Techniques Software Optimisations
  • Performance improvement (cont)
  • use of registers
  • loop unrolling
  • use of pointers
  • loop invariance
  • function in-lining
  • data alignment

48
Coding Techniques Software Optimisations
  • Performance improvement (other from text)
  • scaled arithmetic (incl. binary angular meas.)
  • look-up tables (incl. extrapolation)
  • arithmetic identities
  • loop induction elimination and loop jamming
  • cross jump elimination
  • parameter testing for monotonic functions

49
Multi-tasking
  • Objectives
  • introduce the concept of processes and threads
  • creating processes and threads
  • introduce RTOS terminology
  • identify functions of a real time kernel
  • study different types of real time kernels

50
MultitaskingThe concept of Multi-tasking
  • Fundamental to real-time systems is the concept
    of multi-tasking - the idea that more than one
    program can run on a single processor
  • Processes (Tasks) appear to run simultaneously on
    a system by careful allocation of CPU time
  • For optimum performance this typically involves
    the allocation of a priority to each process

51
MultitaskingThe concept of the Process
  • A process or task is a separate program which is
    run concurrently with other tasks.
  • Each process is scheduled, normally in small
    intervals called time slices
  • The scheduling of the process is modified
    depending on its priority and the availability
    of any resource requested by the process

52
MultitaskingThe concept of the Process
  • Each process uses its own code, data and stack
    areas and can open files and access resources
  • However there are ways in which two or more
    processes may share information (see module 7)
  • command arguments
  • shared memory
  • pipes

53
MultitaskingThe concept of the Process
  • When a process is executed the operating system
  • reads the code from disk and determines the
    initial memory requirements
  • allocates space for the process, typically
    through the memory management system
  • loads the code into memory and initialise it
  • place the process on the appropriate queue

54
MultitaskingThe concept of the Process
  • When a process is running the operating system
  • schedules the process at suitable intervals
  • suspends the process when the time slice ends
  • suspends and reschedules the process when
    resources are unavailable
  • provide resources to the process
  • protects the operating system and other tasks

55
MultitaskingThe concept of the Thread
  • A Thread is a light-weight process
  • A process may own one or more threads
  • Threads are relatively new
  • POSIX library now available for UNIX
  • Windows NT supports threads
  • Threads are loaded with the Process

56
MultitaskingThe concept of the Thread
  • Threads can access their parent processs memory
    space
  • Threads are faster to start than processes
  • Care must be taken when accessing data also
    available to other threads

57
MultitaskingFunctions of a Real Time Op System
  • Task Scheduling
  • Task prioritisation Resource allocation
  • Task Dispatching
  • Context switching
  • Intertask Communications
  • Data passing
  • Signalling

58
Multitasking Implementation of a Real-Time OS
  • The Structure of a RTOS includes
  • the kernel
  • basic input/output
  • extended input/output
  • human interface
  • user applications

59
Multitasking Implementation of a Real-Time Kernel
  • Polled Loop Systems
  • Phase / State Driven Code
  • Co-routines
  • Interrupt Driven Systems
  • Foreground / Background Systems
  • A Full Featured RTOS

60
Task Management Scheduling
  • Objectives
  • learn how real time kernels operate
  • learn how RTOS manage resources
  • understand the services a RTOS provides

61
Task Management SchedulingSystem Implementation
  • Context Switching
  • Stack Model
  • Round-Robin Systems
  • Pre-emptive Priority Systems
  • Rate Monotonic Systems
  • Hybrid Systems

62
Inter-task Communication Synchronisation
  • Objectives
  • extend RTOS terminology
  • learn how data is handled in a RTOS
  • learn how events are handled in a RTOS

63
Inter-task Communications SynchronisationFuncti
ons Required
  • Data Buffering
  • Mail Boxes
  • Critical Regions
  • Semaphores
  • Event Flags Signals

64
Inter-task Communications SynchronisationData
Buffering
  • The Importance of Data Buffering
  • Double Buffering
  • Circular Buffering

65
Real Time Memory Management
  • Objectives
  • discuss memory management issues
  • study memory management schemes

66
Real Time Memory ManagementProcess Stack
Management
  • Task Control Block Model
  • Managing the Stack
  • Run Time Ring Buffer
  • Maximum Stack Size
  • Multiple Stack Arrangements

67
Real Time Memory ManagementDynamic Allocation
  • Swapping
  • Overlays
  • MFT and MVT
  • Demand Paging Replacement
  • Memory Locking
  • Garbage Collection
Write a Comment
User Comments (0)
About PowerShow.com