140 likes | 242 Views
d024: Finish Time in Big Harmonic Periods. Shang-En Huang Team Dont Block Me, National Taiwan University March 26, 2010. Problem Description ( 1/3). There are period task in a task set. For the - th task: Execution time ei : The time needed in one period.
E N D
d024: Finish Time in Big Harmonic Periods Shang-En Huang Team Dont Block Me, National Taiwan University March 26, 2010
Problem Description (1/3) • There are period task in a task set. • For the -th task: • Execution time ei : The time needed in one period. • Period pi : The task must be done in every pi time.
Problem Description (2/3) • We say the periods in a task set is harmonic if for every two tasks Ti and Tj with periods pi < pj , then is a multiple of . • Rate-monotonic scheduling: The task with shorter period have higher priority to be executed.
Problem Description (2/3) • In this problem, the periods in each task set is harmonic and is distinct. • Find the finish time of the task with the largest period using rate-monotonic scheduling.
Example • There are four tasks: • Task 1: need 1 unit in every 2 units. • Task 2: need 1 unit in every 4 units. • Task 3: need 3 units in every 16 units. • Task 4: need 1 units in every 32 units. Answer: 16
A Naïve Method • Simulate by time. • Time complexity . • Each can be as large as . Time Limit Exceeded
Observation (1/2) • Use the fact that the periods are harmonic. • We can sort the tasks by their periods first. • Consider first m tasks only, then the total execution time is fixed in every unit time. • We will know how many time will “reserved” for next task. (The property of rate-monotonic scheduling.)
Observation (2/2) • How to calculate this for first tasks? • In first units of time,task occupied units of time. • Just add them all! • Now, back to the problem: How to find the last execution time for a certain task?
Key to Solution (1/3) • For task , it can use the time only when all the previous tasks are done. • If we want to finish the -th task, then we have to find out the -th “idle time”. • Do adivisionto find the period of -th taskwhere -th “idle time” occurs. How?
Key to Solution (2/3) • Suppose we have “idle time” in every time. • So in the example below, the time we want to findis equal to the -th idle time in time.
Key to Solution (3/3) • But we haven’t count in all ’s execution time. • Therefore the actual “idle time” we need isthe -th “idle time”. • Do this recursively! (By a for-loop is fine.)
The Algorithm • First we check if it is schedulable or not. • Namely, if then it is schedulable. • Then, calculate idle time . • Let , . • For down to 1 do: • Find a period of we want, say -th. • Let .The next idle time we want to find. • Let . • Finally the answer is .
Analysis • We can calculate the idle time of one by one, with total effort . • The total running time is .
Finally… Thanks for your attention!