Final answer:
For thread T1 the CPU utilization is 50%, and combined with T2 it is 66.67%. Both threads can meet their deadlines under EDF scheduling as total utilization is less than 100%. There would be at least one context switch when T2 preempts T1 after its release at 10ms.
Step-by-step explanation:
To calculate the CPU utilization of thread T1, we use the formula:
CPU Utilization = (Execution time / Period)
For T1,
CPU Utilization = (20 ms / 40 ms) = 0.5 or 50%
Now, let's consider thread T2 activating at 10ms.
For T2,
CPU Utilization = (10 ms / 60 ms) = 0.1667 or approximately 16.67%
Combined utilization of T1 and T2:
0.5 + 0.1667 = 0.6667 or 66.67%
Since the total CPU utilization is less than 100%, under EDF (Earliest Deadline First) preemptive scheduling, both threads can meet their deadlines for the hyper-period.
The maximum CPU time for T1 remains 20 ms and for T2 it is 10 ms.
To determine the number of context switches and generate the CPU timing diagram, we would lay out the execution based on deadline priorities.
At 0ms, T1 starts execution as it's the only thread. At 10ms, T2 comes into the picture. With EDF, T2 has a closer deadline, so T1 is preempted.
Here is a sample timing diagram:
- 0-10ms: T1 executes
- 10-20ms: T2 executes
- 20-30ms: T1 resumes and finishes its execution by 30ms
- 30-40ms: Idle since both threads have finished their execution before the next period
Since T1 was interrupted once for T2, there is one context switch. For a complete hyper-period analysis, we would repeat this process for multiples of the least common multiple (LCM) of the periods of T1 and T2. The LCM of 40ms and 60ms is 120ms, so the hyper-period is 120ms.