Skip navigation.
Home
The QNX Community Portal

View topic - Doubt in SIGEV_PULSE_INIT()

Doubt in SIGEV_PULSE_INIT()

Discussion about the QNX6 OS.

Doubt in SIGEV_PULSE_INIT()

Postby hello » Thu Jan 31, 2013 4:26 am

Hi all,

I have configured a timer with timer_create() and timer_settime(). Also registered to notify the threads with a pulse when timeout occurs. My issue is, i have only one timer and i need timeout notification to be send to 2 threads. I have registered for notification using SIGEV_PULSE_INIT() with 2 connection IDs
SIGEV_PULSE_INIT(&t_timer_event,chid1,SIGEV_PULSE_PRIO_INHERIT,TIMER_PULSE,0);
SIGEV_PULSE_INIT(&t_timer_event,chid2,SIGEV_PULSE_PRIO_INHERIT,TIMER_PULSE,0);

But i am receiving the pulse only in one channel. Is this the expected behavior? Is it possible to receive pulse in 2 channels.

Regards,
hello
hello
Senior Member
 
Posts: 101
Joined: Tue May 08, 2012 1:09 pm

Re: Doubt in SIGEV_PULSE_INIT()

Postby maschoen » Thu Jan 31, 2013 7:17 am

Yes, this is the expected behavior.

Note that SIGEV_PULSE_INIT() is not a routine call, but is a macro that sets up data. So you are overwriting the data with the second line.

But that is not your real problem. A timer will only send one pulse. There are various ways around this.
I would suggest one very simple way around the problem.

Instead of setting the timer, create a thread that does the following:
1) sleep for the required amount of time
2) send pulse 1
3) send pulse 2
3) exit the thread
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Re: Doubt in SIGEV_PULSE_INIT()

Postby hello » Thu Jan 31, 2013 7:54 am

For sleep() i would need a dedicated thread, right? To avoid one dedicated thread, i was thinking of such a design. If it does not work, its ok
Consider 2 options:
Option 1: Say i designed a thread and registered to get timer notification pulse. When timeout occurs, thread receives it sends pulse to 2 threads waiting for the timer pulse. So in this design there are altogether 3 threads and one timer.

Option 2: Create 2 timers (for same timeout values), and register to get notification(i.e one timer for one thread). Here, the number of threads is 2, but 2 timers with same timeout value

So which design would you suggest, the 1st or the 2nd.

Regards,
hello
hello
Senior Member
 
Posts: 101
Joined: Tue May 08, 2012 1:09 pm

Re: Doubt in SIGEV_PULSE_INIT()

Postby maschoen » Thu Jan 31, 2013 1:11 pm

I think both would work. I like the idea the of the first notified thread notifying the 2nd better, but I doubt there is much difference in the impact.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Re: Doubt in SIGEV_PULSE_INIT()

Postby hello » Thu Jan 31, 2013 1:42 pm

So increasing the number of timer is more good than creating an additional thread, right ?.
Ok thank you for your opinion

Regards,
hello
hello
Senior Member
 
Posts: 101
Joined: Tue May 08, 2012 1:09 pm

Re: Doubt in SIGEV_PULSE_INIT()

Postby maschoen » Thu Jan 31, 2013 4:57 pm

I don't think it makes much difference. It probably takes more resources to make a thread, but not much.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm


Return to QNX6 - OS

Who is online

Users browsing this forum: No registered users and 6 guests