Timers and events

Hi,
I was wondering if it was possible to attach multiple timers to a single event structure and tell them apart easily (i.e.when they expire and which one expired)? I imagine it is possible but I cannot figure out how to do it.
At the moment, I have timer that sends pulses as an event and the value of event.sigev_value.sival_int is just “1” which is what I print in the handler when the timer expires to say that it was the timer that sent the pulse.
I would like to create several timers that use the same event structure and would allow the handler to print messages such as "timer 1 has just expired, timer 2 has just expired…etc.
Would I have to create an “event2” , make event2.sigev_value.sival_int=2 and attach my second timer to that to be able to distinguish which timer has just expired if I use the same handler??

I hope this question is understandable!! :slight_smile:

Yes your question is understandable.

You don’t have to actually reserve memory for a second event structure, you can simply modify the sival_int value of your single event struct prior to registering it with each of the timers you create. The process manager will make a copy of the structure internal to proc, that it will use when it delivers the event on timer expiry. As long as you know that sival_int == 1 equals timer one, etc, then you’ll be fine.

Thanks! That worked out much better…
I thought that modifying sival_int prior to regestering any addional timers would overwrite the assignment for any previous timers.

Keano - that is what happens on some OSes (read: Solaris). Mostly on systems where the POSIX sigevent system was added after the kernel was desgined. Neutrino was designed around it.