Simvik

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:

  • 2 if it is at most the bound (RM_BOUND[n] × 1000): schedulable,
  • 1 if it is above the bound but at most 1,000,000: the test cannot tell, so response-time analysis is needed,
  • 0 if 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:

2

Above the bound but under 100 %

const ptask_t ts[] = { { 2, 4 }, { 2, 5 } };
printf("%d\n", rm_test(ts, 2));

Expected output:

1

Learn it first

More RTOS scheduling problems