#include #include #include #include #define NFRAME 10 #define NSLOT 2 #define SLOT_T 5000 int tps,slot=0,frame=0; clock_t now, then; struct tms n; void one() { printf("Task 1 running\n"); sleep(1); } void two() { printf("Task 2 running\n"); sleep(1); } void three() { printf("Task 3 running\n"); sleep(1); } void four() { printf("Task 4 running\n"); sleep(1); } void five() { printf("Task 5 running\n"); sleep(1); } /*void burn() { clock_t bstart = times(&n); while ((( now = times(&n)) - then) < SLOT_T * tps / 1000) { } printf (" brn time = %2.2dms\n\n", (times(&n)-bstart)*1000/tps); then = now; cycle = CYCLEX; }*/ void burn() { printf (" brn cycle \n ");} void (*ttable[NFRAME][NSLOT])() = { {one, three}, {two,two}, {one,burn}, {two,two}, {one, burn}, {two,two}, {one,burn}, {four,four}, {two,burn}, {one,burn}}; main() { tps = sysconf(_SC_CLK_TCK); printf("clock ticks/sec = %d\n\n", tps); then = times(&n); while (1) { printf("\n Starting a new hyperperiod \n"); for (frame=0; frame