4 /*===========================================================================*
6 *===========================================================================*/
8 long ticks
; /* number of ticks to wait */
10 /* This function uses the synchronous alarm to delay for a while. This works
11 * even if a previous synchronous alarm was scheduled, because the remaining
12 * tick of the previous alarm are returned so that it can be rescheduled.
13 * Note however that a long tick_delay (longer than the remaining time of the
14 * previous) alarm will also delay the previous alarm.
19 if (ticks
<= 0) return OK
; /* check for robustness */
21 m
.ALRM_EXP_TIME
= ticks
; /* request message after ticks */
22 m
.ALRM_ABS_TIME
= 0; /* ticks are relative to now */
23 s
= _kernel_call(SYS_SETALARM
, &m
);
24 if (s
!= OK
) return(s
);
26 sef_receive(CLOCK
,&m_alarm
); /* await synchronous alarm */
28 /* Check if we must reschedule the current alarm. */
29 if (m
.ALRM_TIME_LEFT
> 0 && m
.ALRM_TIME_LEFT
!= TMR_NEVER
) {
30 m
.ALRM_EXP_TIME
= m
.ALRM_TIME_LEFT
- ticks
;
31 if (m
.ALRM_EXP_TIME
<= 0)
33 s
= _kernel_call(SYS_SETALARM
, &m
);