Setting multiple timers from a single process.

Ravi Ramachandran rr at csuna.cs.uh.edu
Wed Mar 14 15:41:31 AEST 1990


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 
concurrently, and need the ability to restart them or to cancel
them.

My solution at the moment; each time I need a timer (a max of 4
will be needed concurrently), I spawn a child and store the pid
returned to uniquely identify thst timer. The child does a sleep(time)
for the required time. After which SIGCLD goes off. In my interrupt
routine of my main process, I track down which child expired and
determine which timer expired. Dirty, and difficult to manage, but
still workable.


As they said when tearing down the Berlin Wall, "Open to better
suggestions."

  --ravi-



More information about the Comp.unix.wizards mailing list