Os Batch 12
Os Batch 12
SYSTEM
Submitted to: Mr.Sikindhar
BATCH -12
REGDNO NAME
231FA04401 BHARGAV
231FA04B15 SHIVA
231FA04C73 ABHIRAM
231FA04D69 GOWTHAM
QUESTION
Gantt charts, which I introduced in the context of hard-real-time scheduling,
can also be used to illustrate other scheduling concepts, such as those
concerning response time. Suppose thread T1 is triggered by an event at
time 0 and needs to run for 1.5 seconds before it can respond. Suppose
thread T2 is triggered by an event occurring 0.3 seconds later than T1's
trigger, and that T2 needs to run 0.2 seconds before it can respond. Draw a
Gantt chart for each of the following three cases, and for each indicate the
response time of T1, the response time of T2, and the average response
time:
a) T1 is allowed to run to completion before T2 is run.
b) T1 is pre-empted when T2 is triggered; only after T2 has completed does
T1 resume. T1 is preempted when T2 is triggered; the two threads are then
executed in a round-robin fashion (starting with T2), until one of them
completes. The time slice (or quantum) is .05 seconds.
c) What is the Average Response Time for both Non-Preemptive Scheduling
and Preemptive Scheduling algorithms?
a) Non-Preemptive Scheduling (T1 Runs to Completion Before T2)
In this case, T1 runs to completion first before T2 starts. The timeline can
be divided as follows:-
T1 Execution:
T1 starts at time t=0t = 0t=0 and runs for 1.5 seconds until t=1.5t =
1.5t=1.5.
T2 Execution:
T2 starts after T1 completes, at t=1.5t = 1.5t=1.5, and runs for 0.2
seconds until t=1.7t = 1.7t=1.7.
Response Times:
T1 Response Time: 1.51.51.5 seconds (finishes at t=1.5t = 1.5t=1.5).
T2 Response Time: 1.7−0.3=1.41.7 - 0.3 = 1.41.7−0.3=1.4 seconds.
Average=T1 Response Time+T2 Response / 2
Time=1.5 + 1.4 / 2 = 1.45 seconds
B) Case b: Preemptive Scheduling (T1 is preempted when T2 is
triggered)
T1 Execution:
T1 starts at t=0t = 0t=0 and runs until t=0.3t = 0.3t=0.3, when T2 is
triggered.
T2 Execution:
T2 preempts T1 and runs from t=0.3t = 0.3t=0.3 to t=0.5t = 0.5t=0.5
(0.2 seconds).
T1 Resumption:
T1 resumes at t=0.5t = 0.5t=0.5 and completes its remaining execution
by t=1.7t = 1.7t=1.7.
Response Times:
T1 Response Time: 1.71.71.7 seconds (finishes at t=1.7t = 1.7t=1.7).
T2 Response Time: 0.5−0.3=0.20.5 - 0.3 = 0.20.5−0.3=0.2 seconds.
Average Response Time:
B)
C)
THANK YOU