Setting multiple timers from a single process.

Don Libes libes at cme.nist.gov
Thu Mar 15 06:43:36 AEST 1990


In article <24200 at uhnix1.uh.edu> rr at cs.uh.edu writes:
>The subj line says it; I want to set multiple timers from a single
>process. Using alarm() & catching SIGALARM will permit only a single
>timer. I need to set different values for the different timers 
>
>My solution at the moment; [spawn child processes for each timer]

Simulate them by waiting for the shortest one, and keeping track of
the others yourself.  I've done exactly this.  Anyone who wants code
(4.2BSD) can mail me.

Just watch out for things like 1) a timer interrupting your timer
management code, 2) trying to cancel one this is in the process of
going off (or will be by the time you return), 3) getting a new timer
which is shorter than the current one you are waiting for, and 4) the
possibility of several being scheduled for the same time.

Don Libes          libes at cme.nist.gov      ...!uunet!cme-durer!libes



More information about the Comp.unix.wizards mailing list