Date post: | 28-Jan-2018 |
Category: |
Education |
Upload: | kamal-acharya |
View: | 283 times |
Download: | 0 times |
N O T A T I O N S A N D A S S U M P T I O N
S T A T I C , T I M E R - D R I V E N S C H E D U L E R
G E N E R A L S T R U C T U R E O F C Y C L I C S C H E D U L E
C Y C L I C E X E C U T I V E S
I M P R O V I N G T H E A V E R A G E R E S P O N S E T I M E O F A P E R I O D I CJ O B S
S C H E D U L I N G S P O R A D I C J O B S
P R A C T I C A L C O N S I D E R A T I O N S A N D G E N E R A L I Z A T I O N
A L G O R I T H M F O R C O N S T R U C T I N G S T A T I C S C H E D U L E S
P R O S A N D C O N S O F C L O C K - D R I V E N S C H E D U L I N G
Clock Driven Scheduling
Assumptions
To represent the clock driven scheduling following assumptions are used:
System should be deterministic
All parameters of periodic task are known priori
Fixed number of periodic task in system
Variation in inter release time is negligible
For task Ti each job Ji,k is ready for execution at its release time ri,k and released Pi units after previous jobs in Ti
i.e ri,k=ri,k-1+Pi
Aperiodic jobs may exist and may released at unexpected time. Assumption made for them are:
System make a single queue for them
Whenever processor is available for them, job at the head of the queue is executed
Notations
Special notation which consists of four parameters
Ti=(фi , Pi , ei , Di)
Ti is periodic task
фi is phase of task
Pi is the period of task
ei is execution time of the task
Di is the relative deadline of task
Example :
Ti=(1,10,3,6)
Phase is 1, period is 10, execution time is 3 and relative deadline is 6
First job is released and ready at time 1
Must be completed by time 7
Second job is ready at 11
Must be completed by 17 and so on
Default value of phase is 0
Ti=(10,3,6) Phase is 0
Period is 10
Execution time is 3
Relative Deadline is 6
Default value of relative deadline is the period of the task
Ti=(10,3) Phase is 0
Period is 10
Execution time is 3
Relative Deadline is 10
Static , Timer-Driven Scheduler
When all the parameters of the job are known, the static schedules of the job can be developed offline
Processor time allocated to the job is its maximum execution time
Scheduler dispatches the jobs according to the static schedule, repeating the jobs at each hyper-period
Static schedules guarantee that each job completes by its deadline
Let us consider four independent periodic task T1=(4,1), T2=(5,1.8), T3=(20,1) and T4=(20,2)
Their utilization are 0.25, 0.36, 0.05 and 0.1 respectively and total utilization is 0.76
Since LCM of periods is 20, hyper period is 20
Entire schedule consists of replicated segments of length 20
Some periods are not used by the task.
These can be used by aperiodic jobs and background non-relative jobs
Static cyclic schedules can be implemented by using algorithm
The algorithm stores the pre-computed schedule as a table
For given task table has 17 entries as shown below:
K Tk T(tk)
0 0.0 T1
1 1.0 T3
2 2.0 T2
3 3.8 I
4 4.0 T1
5 5.0 I
6 6.0 T4
7 8.0 T2
8 9.8 T1
9 10.8 I
10 12 T2
11 13.8 T1
12 14.8 I
13 16.0 T1
14 17.0 I
15 18.0 T2
16 19.8 I
Table has 17 entries
tk is decision time
T(tk) is the task to be executed or idle interval(I)
During initialization system creates all the task to be executed
At every decision time scheduler decide T(tk) and sets timer to interrupt at next decision time
It then suspend itself and allow the processor to execute the task
General Structure of Cyclic Schedulers
Arbitrary cyclic schedules are flexible but inefficient.
They depend on accurate time interrupt and high scheduling overloads
So clock driven approach is implemented using structural approach rather than tabular approach
Scheduling decision time partition time line into intervals called frames
Scheduling decision are made at the beginning of every frame.
There is no preemption within each frame.
First job of every task is released at the beginning of the frame.
The phase of each periodic task is non-negative integer multiple of frame size
фi=k.f
Gives two benefits
Scheduler can easily check for overrun and missed deadline at the end of each frame
Can use periodic clock interrupt rather than programmable timer.
Frame Size Constraints
To avoid preemption, the frame size should be long enough so that every job start and complete within single frame.
f ≥ max(e1,e2………en)
Hyper period should be an integer multiple of the frame size to minimize the entries.
There should be at least one frame between release and deadline of the job so that scheduler can check if the job has been completed by its deadline
Example: Consider T1=(4,1.0) , T2=(5,1.8) , T3=(20,1.0) and T4=(20,2.0)
Solution:
H=LCM of 4,5,20 and 20=20
Max of 1.0, 1.8, 1.0 and 2.0 is 2.0
i) f≥2
ii) f is either (2,4,5,10,20)
iii) 2f-gcd(Pi,f)≤Di
For f=2 For T1 Pi=4 and Di=4
2*2-gcd(4,2)≤4
4-2≤4
2≤4 (TRUE)
Third condition is satisfied by all the task
F0r f=4,5,10 and 20 Third condition is not satisfied by all the task
Hence the required frame size is 2
Job Slices
Consider three independent tasks T1(4,1), T2(5,2,7) and T3(20,5)
f ≥ 5
Since H is 20, f is either 2,4,5,10,20
2f- gcd(Pi,f) ≤4
≤7
≤20
All the three conditions are not satisfied.
From above example we see that sometime all the three condition are not satisfied by the task.
In such case job with the largest execution time is sliced into sub-jobs with shorter execution time.
Since period of T1 is 4, all five frames are used by it while T2 uses only 4 frames.
So in above example we divide T3(20,5) into chain of three slices as (20,1) , (20,3) and (20,1)
To construct the cyclic schedule we need to make three design constraints
Choose the frame size based on frame constraints
Slice the jobs
Places the slices in frames
These decision cannot be taken independently
Ideally we want as few slices as possible, but forced to generate more slices in order to get the feasible schedule.
Improving Average Response of Aperiodic Jobs
Aperiodic job is released and executed in response to an event.
Sooner the job is completed more responsive the system is.
So minimizing the response time of each aperiodicjobs and average response of all aperiodic jobs is one of design goals.
There is no advantage in giving priority to aperiodicjobs and no advantage in completing the job with hard deadline early.
Figure (a) shows the first major cycle in the cyclic schedule of the periodic tasks
Figure (b) shows three aperiodic jobs A1, A2 and A3
Figure (c) shows when the aperiodic jobs executed when if we use cyclic executive
Figure (d) shows slack stealing
Before Slack Stealing response time of:
A1 is 6.5
A2 is 1.5
A3 is 5.5
After slack stealing response time of:
A1 is 4.5
A2 is 0.5
A3 is 2.5
EDF Scheduling of Accepted jobs
EDF algorithm is a good way to schedule the sporadic jobs.
Scheduler maintains the queue of accepted sporadic jobs in increasing order of their deadlines.
It inserts all the newly accepted sporadic in the queue in the same order.
Below is the example using frame size 4.
Practical Consideration and Generalization
The practical problem faced in clock-driven system mainly fall into three categories
How to handle frame overrun?
How to do mode change?
How to schedule task in multiprocessor system?
Handling Frame Overrun
The frame overrun can occur due to:
Input data dependency
Hardware failure
Software flaws
Frame overrun can be avoided by:
Killing the job that is overrun and starting an error recovery task
Preempting the job and scheduling the remaining job as the aperiodic job
Continue to execute the offending job. The start of the next frame and the execution of jobs in next frame are delayed.
Mode Changes
The number of jobs are fixed in particular mode.
Whenever the mode changes the new jobs may be added or old may be deleted. So new table must be brought into memory along with the code of the task.
Mode change job is released in response to the mode change command.
We assume that periodic tasks are independent and hence can be added and deleted independently.
Aperiodic Mode Change
A way to schedule the mode change job is to treat it like the ordinary aperiodic job.
Except that it may be given highest priority and executed ahead of other aperiodic jobs.
Once the job execute it begin to modify the old schedule in order to speed up the mode change.
Periodic task that will not be executed in new mode is deleted and its memory space and processor time is freed as soon as current job in the task completes.
Sporadic Mode Change
Sporadic job has to be completed by its deadline.
There are two possible way to schedule:
We can treat it like any ordinary sporadic jobs and schedule it.
If the job is not schedulable it can be rejected or the mode change job can be postponed
General Workloads and Multiprocessor Scheduling
As long as all the parameters of the jobs are known priori, a static schedule can be computed offline.
It is then stored in tabular form.
Now global schedule can be constructed which specify on which processor job executes and when.
It is more complex to implement.
Algorithm for Constructing Static Schedules
Iterative Network Flow(INF) Algorithm is used to find out the feasible cyclic schedule if one exist.
It assumes that task can be preempeted at any time and are independent.
In order to apply the INF we first have to find out the frame size of the system.
Consider three independent tasks T1(4,1), T2(5,2,7) and T3(20,5)
Frame size possible are 2 and 4 which still does not satisfy the first requirement.
INF tries to find the feasible cyclic schedule for possible frame size starting from the largest one.
If the algorithm fails to find one , then we can say that no feasible schedule exist even when the job is divided into sub-jobs.
The major component of INF is network flow graph
The constraints on which jobs can be scheduled are represented by network flow graph.
It contains following vertices and edges:
A flow of an edge is a non-negative number satisfying the following conditions:
It is not greater than the capacity of the edge.
With the exception of source and sink , the sum of the flows of all the edges into every vertex is equal to the sum of flows of all the edges out of the vertex
Consider three independent tasks T1(4,1), T2(5,2,7) and T3(20,5)
Frame size possible are 2 and 4 which still does not satisfy the first requirement.
We use INF to find the feasible algorithm.
We draw the network flow graph for frame size 4.