Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

2019HT01605 | VITHYA M | ES ZG553 | REAL TIME SYSTEMS

Birla Institute of Technology & Science, Pilani


Work-Integrated Learning Programmes Division
Second Semester 2019-2020

Mid-Semester Test
(EC-2 Make-up)

Course No. : BITS ZG553 / ES ZG553 / MEL ZG553


Course Title : REAL TIME SYSTEMS
Student Name : VITHYA M
Student ID : 2019HT01605

Question Number Attempted/Not Marks


1 Yes
2 Yes
3 Yes
4 Yes
5 Yes

Q.1. What are the characteristics of Real time system? Explain.


Real time systems Definition:

Real time systems are those which must satisfy bounded response time conditions. These are
systems which respond input stimuli with a specified and finite time.

Eg: Nuclear power plant control monitor, multimedia

Characteristics of real time systems:

Real Time / Time constraints:

Every real time task is associated with some time constraints Eg: Deadline (deadline of the job is the
instance by which its execution is expected to be completed). Real-time system is responsible for the
completion of all tasks within their time intervals.

Correctness:

Correctness of the system not only depends on logical correctness of the system but also on time by
which results are produced. If the result is not obtained within the given time interval then also
result is not considered correct.

Task Criticality:

A critical task is the one whose failure causes system failure.

There are 3 types of real time systems based on deadline

 Hard real time systems – failure to meet deadline can be fatal, and these tasks are critical.
 Soft real time systems – Failure to meet deadline can only lead to performance degradation.
 Firm real time systems - Missing more than a few deadline can lead to complete catastrophic
system failure.
Safety and reliability:

Page 1 of 7
2019HT01605 | VITHYA M | ES ZG553 | REAL TIME SYSTEMS

Real-time systems provide critical safety so such real time systems should be able to operate for long
times, also even during failure it should be able to correct. Safety can be ensured through increased
reliability.

Highly reliable systems can be designed with at least one of the three methods:

 Error avoidance
 Error detection and correction
 Fault tolerance ( provide redundancy )

Concurrency:

Real-time systems are concurrent that means it can respond to a several number of processes at a
time. There are several different tasks going on within the system and it responds accordingly to
every task in short intervals.

Stability:

Even when the load is very heavy, real-time systems should respond in the time constraint i.e. real-
time systems does not delay the result of tasks even when there are several task going on a same
time. This brings the stability in real-time systems

Reactive:

Real-time systems are often reactive. A reactive system is one in which the output generated is used
for further processing. (Kind of feedback system)

Real-time systems do not produce any output data but enter into an on-going interaction with their
environment. In each interaction step, the results computed are used to carry out some actions on
the environment. The reaction of the environment is sampled and is fed back to the system.

Exception Handling:

Real time systems are mostly used in safety critical system. So it should be able to detect failure and
the system should continue to operate in a gracefully degraded mode rather than shutting off
abruptly.

Q.2. What do you mean by hyper period and Make span? Explain. Calculate the hyper period
and make span for the given tasks T(e,p) : T1(2,4), T2(3,8) and T3 (4,16).

Hyper Period (H): Hyper period H of periodic task is the least common multiple of periods of all the
tasks in the set.
H = LCM (p1, p2, p3 ….pk )
The hyper period is the time after which pattern of job release times starts to repeat.

LCM ( 4,8,16) = 16
Hyper period for the set of given tasks is 16

Make span (M): Make span is the time required to complete a group of jobs (All n jobs in a group ).

Page 2 of 7
2019HT01605 | VITHYA M | ES ZG553 | REAL TIME SYSTEMS

Make span is used to compare scheduling algorithm performance. The algorithm which produces a
schedule with shorter make span is better.

M = C-S
M: Make span time of a group of jobs
C: completion time of last job in the Group
S: start time of first job in the group

Assumptions: All the tasks are released at time t= 0.


Make span depends on algorithm- so considering Rate monotonic algorithm with and
Without pre-emption

Total utilisation (U) for the tasks is Sum ( 2/4+ 3/8 + 4/16 ) > 1 = 1.125>1

So these tasks are not schedulable. At least one of the tasks misses deadline.

So considering dual processors:

Q.3. Draw the task precedence graph for a chocolate vending machine in a pantry. Identify the
tasks associated in such a scenario?
Page 3 of 7
2019HT01605 | VITHYA M | ES ZG553 | REAL TIME SYSTEMS

Function: Vending machine is an automatic machine which sells different types of product once the
coin is inserted. Let us consider a simple vending machine whose function is to dispense chocolate
on inserting 5 rupees coin.

Assumption:

 Only one type of chocolate is present with fixed cost.


 Coin of 5Rs denomination can be inserted

Specification:

Input: coin ports

Output: Balance refund and chocolates.

Tasks:

J1: Home screen

J2: Interrupt generated on inserting a coin

J3: Mechanical sorter checks for denomination and count

J4: If the coin is of 5Rs denomination, dispense chocolate equal to number of 5Rs coins inserted
using a mechanical motor.

J5: If the coin is not of 5Rs denomination return the cash.

Task precedence graph:

Q.4. For the task set given, schedule the task according to the deadline monotonic algorithm.

Page 4 of 7
2019HT01605 | VITHYA M | ES ZG553 | REAL TIME SYSTEMS

T1 = (50, 50, 25, 100), T2 = (0, 60, 10, 20), T3 = (0, 125, 25, 50)

Deadline Monotonic algorithm:

With deadline-monotonic priority assignment, tasks are assigned priorities according to their
deadlines. The task with the shortest deadline is assigned the highest priority.

Task Phase period Execution time Relative


deadline

1 50 50 25 100
2 0 60 10 20

3 0 125 25 50

Priority: T2 > T3 > T1

(As T2 has least relative deadline and T1 has highest relative deadline)

At t= 0: T2 and T3 are available and T2 has higher priority, so T2 starts. (J2,1)

At t= 10: As T2 has completed, T3 starts execution (J3,1)

At t= 35: T3 completes execution (J3, 1)

At t= 50: T1 starts execution (J1,1)

At t=60: T2 is released, and T2 has higher priority so T2 starts execution (J2, 2)

At t= 70: T2 completes execution and T1 resumes (J1, 1)

At t= 85: T1 completes execution (J1, 1)

At t= 100: T1 is released and starts execution (J1, 2)

At t= 120: T2 is released and T2 has higher priority so T1 is pre-empted by T2 (J2, 3)

At t= 130: T2 completes execution (J2, 3), and T3 starts execution (J3, 2)

At t= 155: T3 completes execution (J3, 2) and T1 resumes (J1, 2)

At t= 160:T1 completes execution (J1, 2). Third instance of T1 starts (J1, 3)

At t= 180: T2 is released (J2, 4), so T2 pre-empts T1 (J1, 3)

At t= 190: T2 completes execution (J2, 4) and T1 resumes (J1, 3)

At t= 195: T1 completes execution (J1, 3)

At t= 200: T1 is released (J1, 4)

At t=225: T1 completes execution (J1,4)

Page 5 of 7
2019HT01605 | VITHYA M | ES ZG553 | REAL TIME SYSTEMS

Q.5. A system uses the cyclic EDF algorithm to schedule sporadic jobs. The cyclic schedule of
periodic tasks in the system uses a frame size of 5, and a major cycle contains 6 frames.
Suppose that the initial amounts of slack time in the frames are 1, 0.5, 0.5, 0.5, 1, and 1.

(a) Suppose that a sporadic job S (23, 1) arrives in frame 1, sporadic jobs S2(16, 0.8)
and S3(20, 0.5) arrive in frame 2. In which frame are the accepted sporadic jobs scheduled?

Sporadic job deadline Execution Time


S1 –(frame -1) 23 1

S2- (frame -2 ) 16 0.8


S3-( frame -2) 20 0.5

Acceptance test of sporadic Job: let us suppose at the beginning of frame ‘t’, an acceptance test is
done on sporadic job ‘S’ with deadline ‘d’ and execution time ‘e’

Suppose that the deadline of ‘d’ of S is in the frame l+1 and l>t

Hence the job can complete on time only if the current (total) amount of slack time in frames t,t+1,
…..l is greater than execution time ‘e’. The scheduler accepts the job only if the above condition is
satisfied.

S1(23,1) :

Since S1 arrives in frame 1, scheduling decisions about it are made at frame-2.

Frame-2 and frame 3 has a slack of 0.5 each. And frame 3 ends at t=15, before the deadline of S1. So
sum of slack times in frame 2, 3 is greater than the execution time of sporadic job.

The scheduler accepts S1, at start of frame 2. If no other job arrives it would finish by end of frame
3.

S2( 16,0.8):

The scheduler examines S2 at the start of frame-3 (t=10). The deadline is 16 , which is in frame 4, but
there is only 0.5 slack in frame- 3. As S2 cannot be completed before the deadline, scheduler does
not accept S2

Page 6 of 7
2019HT01605 | VITHYA M | ES ZG553 | REAL TIME SYSTEMS

S3(20,0.5)

The scheduler examines S2 at the start of frame-3 (t=10). Deadline is 20m which is in beginning of
frame 5. There is 1 unit of slack time between frame 3 and frame 5. However the scheduler need to
see if the job can be executed without affecting the already accepted job. Earliest deadline first
algorithm is used, so if S3 is accepted, S3 will have higher priority that S1, so S3 will complete its
execution and then s1 will complete the remaining 0.5 execution and will complete by frame-4.

So as it can meet the deadline, S3 will be accepted by the scheduler

(b) Suppose that an aperiodic job with execution time 3 arrives at time 1. When will it be
completed, if the systems does not do slack stealing?

Assumption: sub-division a) should also be considered. i.e sporadic jobs S1,S2,S3 are also released

Let us consider an aperiodic job, K with execution time of 3 and release time 1. Scheduler runs K in
slack of first frame. As the slack time from frames 2,3,4 is consumed by the sporadic job S1,S3,
aperiodic job continues in frame 5,6 and completes execution by end of frame 6 which is time t= 30

Assumption: when only aperiodic jobs are released

Let us consider an aperiodic job, K with execution time of 3 and release time 1.

Scheduler runs K in slack of all frames from (1-5). Aperiodic job completes is execution by frame - 5
(time t = 24.5)

THE END

********

Page 7 of 7

You might also like