1
/* alarm.c -- wakeup calls */
4
-- Implementation of alarm.h
13
static int alarmPending = 0; /* Nonzero when the alarm is set. */
16
static void AlarmHandler();
21
struct sigaction handler;
24
handler.sa_handler = AlarmHandler;
25
sigemptyset(&handler.sa_mask);
27
sigaction(SIGALRM, &handler, NULL);
28
ualarm(1000 * time, 0);
32
-- If an alarm signal is lurking (due to a prior call to SetAlarm), then
33
-- pause until it arrives. This procedure could have simply been written:
34
-- if (alarmPending) pause();
35
-- but that allows a potential race condition.
46
static void ualarm(us)
49
struct itimerval rttimer, old_rttimer;
51
rttimer.it_value.tv_sec = us / 1000000;
52
rttimer.it_value.tv_usec = us % 1000000;
53
rttimer.it_interval.tv_sec = 0;
54
rttimer.it_interval.tv_usec = 0;
55
if (setitimer(ITIMER_REAL, &rttimer, &old_rttimer)) {
62
static void AlarmHandler()