Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 32

TN 324: INTELLIGENT

INSTRUMENTATION
Instructor: Mr. Mwalongo M, R

(Assistant Lecturer)

Office No: AB 12 (Admin Block)

E-mail: mwalongomarko@gmail.com
LECTURE 4:
CONCEPTS OF REAL TIME SYSTEM
AND ITS APPLICATION
REAL TIME SYSTEM - INTRODUCTION
 Real-time system is a system in which some specific work has to be
done in a specific time period. Or
 Systems controlled by embedded software whose behavior is subject
to timing constraints.
o  Timeliness is the single most important aspect of a real-time system.
o These systems respond to a series of external inputs, which arrive in
an unpredictable fashion.
o  By definition Real-Time systems are as those systems in which the
correctness of the system depends not only on the logical result of
computation, but also on the time at which the results are produced.
If the timing constraints are not met, system failure is said to have
3

occurred.
REAL TIME SYSTEM - INTRODUCTION
o Note that the delivery of results at the correct time is the critical
distinguishing feature of a real-time system.
o In some ways, you could consider some systems such as
systems which pay salaries every month to be real-time systems
as they must complete their processing by the end of the month
so that people will be paid on time.
o However, we normally restrict the term real-time systems to
systems whose response time must be seconds or less.

4
REAL -TIME HISTORY

o The term real time derives from its use in early


simulation. While current usage implies that a
computation that is 'fast enough' is real time, originally it
referred to a simulation that proceeded at a rate that
matched that of the real process it was simulating.
o However, several coding libraries exist which offer real
time capabilities in a high level language on a variety of
operating systems, for example Java Real Time. 5
TYPES OF REAL TIME SYSTEM
There are three types of real time systems

 Hard Real time systems

 Soft Real-Time systems

 Firms Real-Time systems

6
HARD REAL TIME SYSTEM
o The classical conception is that in a hard real-time system, the
completion of an operation after its deadline is considered useless
ultimately, this may lead to a critical failure of the complete
system or whose operation is incorrect if results are not produced
according to the timing specification.
o Example: For example consider systems that have to open a
valve within 30 milliseconds when the humidity crosses a
particular threshold. If the valve is not opened within
30milliseconds a catastrophe may occur. Such a systems with
strict deadline are called hard real-time systems.
o Another example, a car engine control system is a hard real-time
system because a delayed signal may cause engine failure or
damage.
7
SOFT REAL TIME SYSTEM
o A ‘soft’ real-time system is a system whose operation is degraded if
results are not produced according to the specified timing
requirements. On the other hand will tolerate such lateness, and
may respond with decreased service.
o Deadlines are imposed but not adhering to them once in a while
may not lead to the a catastrophe .
o Example for DVD player, suppose you give a command to DVD
player from remote control and there is a delay for few
milliseconds in executing that command but the delay won’t lead to
a serious implication, such system is called soft real-time systems.
8
SOFT REAL TIME SYSTEM

o Another example: the software that maintains and updates


the flight planes for commercial airliners. These can operate
to a latency of seconds.
o Live audio-video systems are also usually soft real-time;
violation of constraints results in degraded quality, but the
system can continue to operate.

9
FIRM REAL TIME SYSTEM

o Firm real - time system - This is a combination of both


hard and soft timeliness requirements. The computation
has a shorter soft requirement and a longer hard
requirement.
o For example, a patient ventilator must mechanically
ventilate the patient a certain amount in a given time
period. A few seconds' delay in the initiation of breath is
allowed, but not more than that.
10
CHARACTERISTICS OF REAL TIME
SYSTEM

 Large and complex

 Concurrent control of system components

 Facilities for hardware control

 Extremely reliable and safe

 Real-time facilities

 Efficiency of execution 11

 
A REAL-TIME SYSTEM MODEL

12
A REAL-TIME SYSTEM MODEL. CONT.

o The real-time system is a software system which is


interfaced to hardware which constitutes part of the R-T
systems environment.
o The R-T system finds out information from its
environment through a set of sensors (e.g. temperature
sensors, radars, fuel flow measurement sensors, infra-
red movement detectors, etc.) and instruct a set of
actuators to make changes to the environment.
13
A REAL-TIME SYSTEM MODEL. CONT.
o Actuators are devices such as heating or refrigeration
elements (to change the temperature of the
environment), pumps, motors to move things around
etc.
o Large real-time systems can have hundreds of sensors
and actuators associated with them. Instruct a set of
actuators to make changes to the environment.

14
STIMULUS/RESPONSE SYSTEMS
o A stimulus is an event which indicates that the system should take
some action.

Stimuli usually fall into two classes:


o Stimuli from a system clock. Every so often, the system
responds to a clock tick and does something such as interrogate a
sensor.
o Stimuli from an interrupt system. An interrupt is a hardware
signal which interrupts whatever processing is going on and
causes the system to transfer its attention to something else.
Interrupts are used where there is a need for rapid, high-priority
processing e.g. some emergency which must be dealt with
immediately. 15
STIMULUS/RESPONSE SYSTEMS

 Given a stimulus, the system must produce a response within a


specified time.
 Periodic stimuli. Stimuli which occur at predictable time
intervals.
 For example, a temperature sensor may be polled 10 times
per second.
 Aperiodic stimuli. Stimuli which occur at unpredictable times.
 For example, a system power failure may trigger an
interrupt which must be processed by the system.
16
SYSTEM ELEMENTS
 Sensors 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
 Generates control signals for the actuator.

17
ARCHITECTURAL CONSIDERATIONS
 Real-time systems are usually designed as cooperating processes
with a real-time executive controlling these processes

 Because of the need to respond to timing demands made by


different stimuli/responses, the system architecture must allow for
fast switching between stimulus handlers.

 Timing demands of different stimuli are different so a simple


sequential loop is not usually adequate.

 Almost all real-time systems are designed as a set of parallel


processes whose operation is switched on and off by a centralized
scheduling system. The advantage of this approach is that a
process can be executed when it is required and, when it doesn’t
have any information to process, it can be stopped and the
processor used for other computation.
18
R-T SYSTEMS DESIGN PROCESS
o Identify the stimuli to be processed and the required
responses to these stimuli.
 For each stimulus and response, identify the timing constraints.
Note that the identification of timing constraints comes very
early in this process. You need to think about this at this stage
because getting the timing right is critical.

o Aggregate the stimulus and response processing into


concurrent processes. A process may be associated with each
class of stimulus and response.
19
R-T SYSTEMS DESIGN PROCESS
o Design algorithms to process each class of stimulus and response.
These must meet the given timing requirements.
o Design a scheduling system which will ensure that processes are
started in time to meet their deadlines.
o Integrate using a real-time executive or operating system.
o In order to understand how stimuli are processed and the ways in
which the system’s environment should be changed by actuators,
you have to understand the application domain of the system.
That is, if the system is to control a chemical plant, you need to
understand chemical plants; if the system is to control a video
recorder, you need to understand video signals, etc.
20
REAL TIME OPERATING SYSTEM

o A real-time operating system (RTOS) is a multitasking


operating system intended for real-time applications.
o Such applications include embedded systems
(programmable thermostats, household appliance
controllers, mobile Telephones), industrial robots,
spacecraft, industrial control (SCADA), and scientific

research equipment.
21
REAL TIME OPERATING SYSTEM. CONT.
 A RTOS facilitates the creation of a real-time system, but does not
guarantee the final result will be real-time; this requires correct
development of the software.
 A RTOS does not necessarily have high throughput; rather, an RTOS
provides facilities which, if used properly, guarantee deadlines can
be met generally (soft real-time) or deterministically (hard real-
time).
 A RTOS will typically use specialized scheduling algorithms in
order to provide the real-time developer with the tools necessary to
produce deterministic behaviour in the final system.
 A RTOS is valued more for how quickly and/or predictably it can
respond to a particular event than for the given amount of work it
can perform over time. 22
REAL TIME OPERATING SYSTEM. CONT.
o Key factors in a RTOS are therefore minimal interrupt latency and a
minimal thread switching latency.
 Must provide memory sharing threads
 Must provide efficient tasking (context) switching
 Should provide synchronization mechanism
 Advanced RTOS may provide task scheduling
 Examples for Real Time Operating System: 
 QNX, RTLinux, VxWorks and Windows CE (Read for more
23

details!!!)
DESCRIPTION OF REAL TIME OPERATING
SYSTEM
o Description of Real Time Operating System There are
additional fundamental aspects of RTOS design.
o One is the ability of a particular process to communicate with
another process (formally called interprocess communication
or IPC). This allows separate applications to interact with each
other and share the same data.
o The concept of IPC introduces another important operating
system aspect, preventing a process from changing data while
24
another process is using the data.
EXECUTIVE COMPONENTS:
Real-time clock
o A clock which ticks periodically (typically every few

milliseconds but it can be faster or slower than this). At each


clock tick, the executive makes decisions on what processes
should be scheduled
Interrupt handler
o Interrupt is hardware device which causes the current process to

be suspended and control transferred to an interrupt handler


which can then start another process to deal with the interrupts.
Interrupts are either clock interrupts (this is how the systems
knows when to switch between processes) or other interrupts
(such as a power failure interrupt) which indicates that some
exception has occurred.
25
EXECUTIVE COMPONENTS:

Scheduler
o Decides which process should be run

Resource manager
o Allocates resources (e.g. memory) to the scheduled process

Dispatcher
o Starts execution of a process on a processor Scheduler

26
EXECUTIVE COMPONENTS: CONT.

Minimizing Latency
Latency
The time interval between the instant at which an instruction control unit
issues a call for data and the instant at which the transfer of data is
started.

 Consider the event-driven nature of a real-time system: The system is


typically waiting for an event in real time to occur. Events may arise
either in software as when a timer expires or in hardware as when a
remote controlled vehicle detects that it is approaching an obstruction.
 When an event occurs, the system must respond to and service it as
quickly as possible.
 We refer to event latency as the amount of time that elapses from when
an event occurs to when it is serviced

There 2 types of latency


 Interrupt Latency 27

 Dispatch Latency
INTERRUPT LATENCY
o Interrupt latency is the period of time from when an interrupt
arrives at the CPU to when it is serviced

28
INTERRUPT LATENCY
Interrupt Latency
 Period of time from arrival of interrupt to start of ISR (interrupt
service routine).
 OS must complete process that was running + save the status of
the current process before switching.
 Total time for the above tasks = interrupt latency

 For RTOS it is min to ensure all critical tasks be completed on


time.
 For hard real time: interrupt latency must be minimized and
bounded to guarantee the deterministic behavior required of hard
real-time kernels.

29
DISPATCH LATENCY
 The amount of time required for the scheduling dispatcher to
stop one process and start another.
 It must be minimum.

30
ASSIGNMENT

o Real-time computing plays a crucial role in our


society, since an increasing number of complex
systems rely, in part or completely, on computer
control. Then briefly explain the area where a real
time can be applicable

31
32

You might also like