Cyclic executive with timer

I need to develop a cyclic executive. Currently i’m using a real time timer created with timer_create().

I have seen in the examples in the QNX Neutrino library reference that the timer firing is associated to a pulse, however, i want to use the default SIGALRM signal generated by the timer with the handler installed by signalaction() or waiting the event using sigwait().

My doubt is: this could work? should i use a SIGUSRX signal instead?

Thanks in advance,

Alex

I think QNX’s documentacion is very complete and it said all you need in “Clocks, Timers, and Getting a Kick Every So Often”…

From the docs:

Notification schemes

With periodic and one-shot timers, you have a choice:

  • send a pulse
  • send a signal
  • create a thread

The answers:

  1. It works
  2. Yes, you can.

Regards,
Juan Manuel

Thanks Juan Manuel,

Another doubt rises…What happens with my process if another one delivers a SIGALRM?

Regards,

Alex

Hum… I’m not sure but I think when the signal arise to your program, your handler catch it and call to some function (?), so that signal is masked to avoid nested signals and if someone send a signal of the same type (number) again it’s enqueued, so when you return from your handler the signal is unmasked, so if there is a pending signal you will catch it again…

Regards,
Juan Manuel

ok, i guess it’s the reason to use pulses with a dedicated channel instead the signals.

I’ll continue reading, and thanks a lot Juan Manuel.

Alex

Pulses are also enqueued if the receiver isn’t blocked waiting for it… !!! You have to take care of that types of things…

The main reason to use a timer with pulses or signals, as I understand, is that pulses needs a MsgReceive() or MsgReceivePulse() in main loop and your pulse will be distingished at that point, while sending periodics signal needs a handler that catch them interrupting the normal execution sequence.

It’s all about what do you need. If your process already have a MsgReceive in main loop, and you need just to distingish if a pulse or an outside msg you can do something like:

while ( FOR_EVER )
{
rcvid = MsgReceive (chid, …)
{
if (rcvid == 0)
{
// you got a pulse
}
else
{
// you a got a message
}
}
}

If you use signals… you’ll need a handler.

Regards,
Juan Manuel

Only one signal can be queued. That’s why it’s called a pending signal it’s now really a queue.

Thank you Mario!

But the quote talks about pulses?..

The post said “Pulses are ALSO enqueued”, which I though referred to signals.

Ah… ok… your are right!! Thanks for the clarification Mario!.