2 #include <minix/timers.h>
4 /*===========================================================================*
6 *===========================================================================*/
7 int tickdelay(clock_t ticks
)
9 /* This function uses the synchronous alarm to delay for a while. This works
10 * even if a previous synchronous alarm was scheduled, because the remaining
11 * tick of the previous alarm are returned so that it can be rescheduled.
12 * Note however that a long tick_delay (longer than the remaining time of the
13 * previous) alarm will also delay the previous alarm.
18 if (ticks
<= 0) return OK
; /* check for robustness */
20 m
.ALRM_EXP_TIME
= ticks
; /* request message after ticks */
21 m
.ALRM_ABS_TIME
= 0; /* ticks are relative to now */
22 s
= _kernel_call(SYS_SETALARM
, &m
);
23 if (s
!= OK
) return(s
);
25 sef_receive(CLOCK
,&m_alarm
); /* await synchronous alarm */
27 /* Check if we must reschedule the current alarm. */
28 if (m
.ALRM_TIME_LEFT
> 0 && m
.ALRM_TIME_LEFT
!= TMR_NEVER
) {
29 m
.ALRM_EXP_TIME
= m
.ALRM_TIME_LEFT
- ticks
;
30 if (m
.ALRM_EXP_TIME
<= 0)
32 s
= _kernel_call(SYS_SETALARM
, &m
);