[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Millisecond-based alarm
I found Talarm to be pretty reliable, but I needed finer resolution, so I've
added a Tmalarm that doesn't convert to seconds, etc. Talarm just calls
Tmalarm now. It seems like a useful addition, what do you folks think?
*** 1.1 1994/01/30 14:11:23
--- dos.c 1994/01/30 14:29:10
***************
*** 360,363 ****
--- 360,378 ----
{
long oldalarm;
+ oldalarm = t_malarm(x*1000);
+ oldalarm = (oldalarm+999) / 1000; /* convert to seconds */
+ return oldalarm;
+ }
+
+ /*
+ * t_malarm(x): set the alarm clock to go off in "x" milliseconds. returns
+ * the old value ofthe alarm clock
+ */
+
+ long ARGS_ON_STACK
+ t_malarm(x)
+ long x;
+ {
+ long oldalarm;
TIMEOUT *t;
***************
*** 378,383 ****
}
- oldalarm = (oldalarm+999) / 1000; /* convert to seconds */
-
/* we were just querying the alarm */
if (x < 0)
--- 393,396 ----
***************
*** 388,394 ****
canceltimeout(curproc->alarmtim);
! /* add a new alarm, to occur in 1000*x milliseconds */
if (x)
! curproc->alarmtim = addtimeout(1000*x, alarmme);
else
curproc->alarmtim = 0;
--- 401,407 ----
canceltimeout(curproc->alarmtim);
! /* add a new alarm, to occur in x milliseconds */
if (x)
! curproc->alarmtim = addtimeout(x, alarmme);
else
curproc->alarmtim = 0;
***************
*** 589,591 ****
--- 602,605 ----
dos_tab[0x13b] = d_getcwd;
dos_tab[0x13c] = s_alert;
+ dos_tab[0x13d] = t_malarm;
}
*** 1.3 1994/01/30 13:04:54
--- proto.h 1994/01/30 14:22:44
***************
*** 86,89 ****
--- 86,90 ----
long ARGS_ON_STACK p_pause P_((void));
long ARGS_ON_STACK t_alarm P_((long x));
+ long ARGS_ON_STACK t_malarm P_((long x));
long ARGS_ON_STACK s_ysconf P_((int which));
long ARGS_ON_STACK s_alert P_((char *msg));