Skip navigation.
Home
The QNX Community Portal

View topic - Cyclic executive with timer

Cyclic executive with timer

For discussion of realtime and/or embedded programming.

Cyclic executive with timer

Postby parrado » Fri Jan 16, 2009 11:50 pm

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
parrado
Active Member
 
Posts: 20
Joined: Sat Oct 25, 2008 2:39 pm

RE: Cyclic executive with timer

Postby juanplacco » Sat Jan 17, 2009 1:39 am

I think QNX's documentacion is very complete and it said all you need in "Clocks, Timers, and Getting a Kick Every So Often"...

I have seen in the examples in the QNX Neutrino library reference that the timer firing is associated to a pulse


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
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby parrado » Sat Jan 17, 2009 4:05 am

Thanks Juan Manuel,



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


Regards,

Alex
parrado
Active Member
 
Posts: 20
Joined: Sat Oct 25, 2008 2:39 pm

Postby juanplacco » Sat Jan 17, 2009 7:42 am

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
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby parrado » Sat Jan 17, 2009 4:53 pm

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
parrado
Active Member
 
Posts: 20
Joined: Sat Oct 25, 2008 2:39 pm

Postby juanplacco » Sat Jan 17, 2009 6:29 pm

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
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby mario » Mon Jan 19, 2009 1:55 pm

juanplacco wrote:Pulses are also enqueued if the receiver isn't blocked waiting for it.... !!! You have to take care of that types of things...


Only one signal can be queued. That's why it's called a pending signal it's now really a queue.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby juanplacco » Mon Jan 19, 2009 3:39 pm

Thank you Mario!

But the quote talks about pulses?...
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby mario » Mon Jan 19, 2009 3:47 pm

The post said "Pulses are ALSO enqueued", which I though referred to signals.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby juanplacco » Mon Jan 19, 2009 4:26 pm

Ah... ok... your are right!! Thanks for the clarification Mario!.
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm


Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 4 guests