Previously, there was a tiny chance that tickdelay(3) would return early or that it would fail to reinstate a previous alarm. - sys_setalarm(2) now returns TMR_NEVER instead of 0 for the time left if no previous alarm was set; - sys_setalarm(2) now also returns the current time, to allow the caller to determine whether it got an alarm notification for the alarm it set or for a previous alarm that has just gone off; - tickdelay(3) now makes use of these facilities. Change-Id: Id4f8fe19a61ca8574f43131964e6f0317f613f49
27 lines
742 B
C
27 lines
742 B
C
#include "syslib.h"
|
|
|
|
/*
|
|
* Ask the kernel to schedule a synchronous alarm for the caller, using either
|
|
* an absolute or a relative number of clock ticks. Optionally return the time
|
|
* left on the previous timer (TMR_NEVER if none was set) and the current time.
|
|
*/
|
|
int
|
|
sys_setalarm2(clock_t exp_time, int abs_time, clock_t * time_left,
|
|
clock_t * uptime)
|
|
{
|
|
message m;
|
|
int r;
|
|
|
|
m.m_lsys_krn_sys_setalarm.exp_time = exp_time; /* expiration time */
|
|
m.m_lsys_krn_sys_setalarm.abs_time = abs_time; /* time is absolute? */
|
|
|
|
if ((r = _kernel_call(SYS_SETALARM, &m)) != OK)
|
|
return r;
|
|
|
|
if (time_left != NULL)
|
|
*time_left = m.m_lsys_krn_sys_setalarm.time_left;
|
|
if (uptime != NULL)
|
|
*uptime = m.m_lsys_krn_sys_setalarm.uptime;
|
|
return OK;
|
|
}
|