Hi, Yes I think you’re right. Indeed the machine has one timer interrupt and it’s enough for the kernel to demultiplex it over many processes who each can have different alarm requirments.
Thx. > On May 2, 2015, at 8:06 AM, erik quanstrom <quans...@quanstro.net> wrote: > >> I’m not sure I understand your proposal. >> >> But looking more at the code I need to port, an interpreter, I think >> the main issue is that the interpreter relies on sigvtalarm as >> a way to preempt the interpreted program while allowing >> the user program to use only sigalarm. So more generally >> the problem is how can I have two alarms in plan9? I see only >> one alarm signal in ape, SIGALRM. There is no SIGVTALRM. > > the standard way to do this is as the kernel does. the kernel typically > keeps one highres timer (per core), and a linked list of events sorted by > alarm > time. when the alarm fires, do the action associated with each alarm that has > passed and reload periodic timers. this is in port/portclock.c. i'm sure > there > are implementations of this algorithm elsewhere, too. > > - erik >