Esempio n. 1
0
/** Process any expired timers.
 * Calls the functions of expired timers and removes them
 * from the timer list.
 * Reschedules the interval timer for the earliest expiring timer
 * (if any).
 *
 * Should not be called from within the SIGALRM handler - set
 * a flag there and call it later.
 *
 * @return 0 on success, error code otherwise.
 */
int process_timers(void) {
    double now = time_now();
    Timer *curr, *next;
    for(curr = timers; curr; curr = next) {
        next = curr->next;
        if(curr->expiry > now) break;
        if(curr->fn) curr->fn(curr->data);
    }
    timers = curr;
    itimer_set((curr ? curr->expiry : 0));
    return 0;
}
Esempio n. 2
0
void Timer_add(Timer *timer) {
    // Insert timer in list ordered by (increasing) expiry time.
    Timer *prev, *curr, *next;
    prev = NULL;
    for(curr = timers; curr; prev = curr, curr = next) {
        next = curr->next;
        if(timer->expiry < curr->expiry) break;
    }
    if(prev) {
        prev->next = timer;
    } else {
        timers = timer;
    }
    timer->next = curr;

    // Set interval timer to go off for earliest expiry time.
    itimer_set(timer->expiry);
}
Esempio n. 3
0
int do_itimer (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
    {
    itimer_set();

    return OK;
    }