[comp.os.minix] bug in alarm

bing@galbp.UUCP (09/30/87)

there seems to be a bug in the way alarms are handled in minix. i noticed the
problem only by accident. on my minix i have gotten rid of the ram disk and use
my hard disk as root. this means every 30 seconds when update does a sync(), 
my hard disk light blinks. i was playing around with a small program that made
an alarm() call when i noticed update stopped running.

upon further investigation, i found out that if two processes are waiting
on an alarm, under an unknown set of circumstances, the second process (the one
with the longer alarm time) never receives a signal. i am trying to find the
bug now, below is the test program i use. it should run forever if alarm()
works ok, but now it stops after 1 or 2 itterations.

------------------------------------------------------------------------
#include <signal.h>

int pid, catcher();

main()
{
	pid = fork();

	for( ; ; )
		{
		signal(SIGALRM, catcher);
		alarm(pid?5:7);
		pause();
		}
}

int
catcher()
{
	if(pid)
		write(1, "\nparent alarm.\n", 15);
	else
		write(1, "\nchild alarm.\n", 14);
}
-- 
Bing H. Bang                         +-------------------+
Harris/Lanier                        |MSDOS: just say no.|
Atlanta GA                           +-------------------+

ast@star.UUCP (10/02/87)

In article <1767@galbp.LBP.HARRIS.COM> bing@galbp.UUCP (Bing Bang) writes:
>there seems to be a bug in the way alarms are handled in minix.

I think the fix Henri Bal posted to line 6617 a few days ago fixes this.
Try it and see.

Andy Tanenbaum (ast@cs.vu.nl)