/** * Makes task wait for next period * @param i task index */ void wait_for_period(int i) { clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &(tp[i].at), NULL); time_add_ms(&(tp[i].at), tp[i].period); time_add_ms(&(tp[i].dl), tp[i].period); }
void wait_for_period(task_par_t *tp) { clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &(tp->at), NULL); time_add_ms(&(tp->at), tp->period); time_add_ms(&(tp->dl), tp->period); }
void set_period(task_par_t *tp) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); time_copy(&(tp->at), t); time_copy(&(tp->dl), t); time_add_ms(&(tp->at), tp->period); time_add_ms(&(tp->dl), tp->deadline); }
/** * Sets next activation time. Here absolute deadlines are considered * @param i task index to be activated */ void set_next_activation(int i) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); time_copy(&(tp[i].at), t); time_copy(&(tp[i].dl), t); time_add_ms(&(tp[i].at), tp[i].period); time_add_ms(&(tp[i].dl), tp[i].deadline); }
void set_period_ms(struct timespec *at, struct timespec *dl, long period, long deadline, const struct timespec *t0, long phase) { struct timespec t; if (t0 == NULL) clock_gettime(CLOCK_MONOTONIC, &t); else time_cpy(&t, t0); time_add_ms(&t, phase); time_cpy(at, &t); time_cpy(dl, &t); time_add_ms(dl, deadline - period); }
void wait_for_period_ms(struct timespec *at, struct timespec *dl, long period) { clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, at, NULL); time_add_ms(at, period); time_add_ms(dl, period); }