Example SPAK code
for analyzing the robustness of a task set:
int main (void)
double cs, overrun;
struct task_set *ts, *ts2, *ts3;
int feas;
FILE *outf;
// set the response-time limit over which the analysis should bail
max_resp = 100000;
/*
* create a task set that can contain at most two
* tasks and use Tindell's response time analysis
*/
ts = create_task_set (2, 0, 0, 0,
"robustness example",
1000, 0, 0, 0,
"Tindell92_restricted");
// C T D J B name
new_simple_task (ts, 400, 1999, 1999, 0, 0, "t1");
new_simple_task (ts, 400, 2000, 2000, 1200, 0, "t2");
// create a fully preemptive, deadline-monotonic schedule
set_priorities (ts, DM);
make_all_preemptible (ts);
// perform a response time analysis for all tasks
feas = feasible (ts, TRUE);
// print some stuff
printf ("original task set has %d feasible tasks:\n", feas);
print_task_set (ts);
printf ("\n\n");
/*
* do a bunch of simulation runs with max overrun between
* 0% and 100%, logging number of deadline misses per run
* to a file
*/
outf = fopen ("dm.dat", "w");
assert (outf);
for (overrun = 0; overrun <= 1.0; overrun += 0.01) {
simulate (ts, 50000000, NULL, overrun, "DM schedule", outf);
}
fclose (outf);
// compute critical scaling factor of this schedule
cs = find_critical_scale (ts, &ts2);
printf ("critical scaling factor is %f\n", cs);
printf ("scaled task set with DM schedule:\n");
print_task_set (ts2);
free_task_set (ts2);
printf ("\n\n");
/*
* find the most robust schedule -- not too hard in this
* case since there are only two possible schedules!
*/
ts2 = maximize_insensitivity_optimal (ts);
/*
* do a bunch of simulation runs with max overrun between
* 0% and 100%, logging number of deadline misses per run
* to a file
*/
outf = fopen ("robust.dat", "w");
assert (outf);
for (overrun = 0; overrun <= 1.0; overrun += 0.01) {
simulate (ts2, 50000000, NULL, overrun, "robust schedule", outf);
}
fclose (outf);
// compute critical scaling factor of this schedule
cs = find_critical_scale (ts2, &ts3);
printf ("critical scaling factor is %f\n", cs);
printf ("scaled task set with maximally robust schedule:\n");
print_task_set (ts2);
printf ("\n\n");
free_task_set (ts3);
free_task_set (ts2);
free_task_set (ts);
return 0;
}
Back to the main SPAK page.