Rate-monotonic utilisation test
Decide from CPU utilisation whether a task set is schedulable under rate-monotonic priorities. A medium embedded C problem (RTOS scheduling), run and graded…
medium · RTOS scheduling · rtos · scheduling · analysis
Liu and Layland proved that n periodic tasks with rate-monotonic priorities (shorter period, higher priority) always meet their deadlines if the total CPU utilisation is at most n(2^(1/n) − 1).
Compute the utilisation in parts per million: the sum of c × 1,000,000 / t over the tasks (each term rounded down; c is at most 4000). Then return:
2if it is at most the bound (RM_BOUND[n] × 1000): schedulable,1if it is above the bound but at most 1,000,000: the test cannot tell, so response-time analysis is needed,0if it is above 1,000,000: overloaded, no schedule can work.
There are 1 to 8 tasks.
Starter code
int rm_test(const ptask_t *tasks, int n) {
return 2;
}Example tests
A light load
const ptask_t ts[] = { { 1, 4 }, { 1, 5 }, { 1, 10 } };
printf("%d\n", rm_test(ts, 3));Expected output:
2Above the bound but under 100 %
const ptask_t ts[] = { { 2, 4 }, { 2, 5 } };
printf("%d\n", rm_test(ts, 2));Expected output:
1Learn it first
- RTOS scheduling and timing · Preemption, context switches, ticks and rate-monotonic analysis.
More RTOS scheduling problems
- Drift-free periodic wake-up · Compute how long a periodic task should sleep so its period never drifts.
- Response-time analysis · Compute worst-case response times under fixed-priority scheduling and check every deadline.
- Find the highest ready priority · Pick the highest priority from a 32-bit ready bitmap.
- Priorities with round-robin · Choose the next task to run, sharing the CPU in turns among tasks of equal priority.
- Earliest-deadline-first schedule · Simulate an EDF scheduler tick by tick, draw the timeline and count missed deadlines.
- Priority inversion, tick by tick · Simulate a preemptive scheduler with a shared mutex, and see what priority inheritance changes.
- Ventilator: will every task meet its deadline? · Prove the ventilator's tasks are schedulable with response-time analysis, not just a utilisation total.