It is not working for me… .Any significance of scavenger_pulse_code? I
see that it is not declared here …and it is not declared in any of the
system header files.I see that all the return values are Success ,but i
don’t see that the timer function being called.
Sreekanth
“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:amtlrd$lo$1@nntp.qnx.com…
I would still suggest the “pulse way”. Here is the piece code
send to Sreekanth via email (note inside the io-net, the dpp
is already created and passed down…):
int callback(message_context_t *ctp, int code, unsigned flags, void hdl)
{
/ do timeout process */
return 0;
}int main()
{
dispatch_t *dpp;
int coid;
struct sigevent ev;
timer_t callback_timer;dpp = dispatch_create();
coid = message_connect(dpp, 0);
ev.sigev_code = scavenger_pulsecode = pulse_attach(dpp,
MSG_FLAG_ALLOC_PULSE, 0, callback, 0);
ev.sigev_notify = SIGEV_PULSE;
ev.sigev_value.sival_int = 0;
ev.sigev_coid = coid;
ev.sigev_priority = 1;
timer_create(CLOCK_REALTIME, &ev, &callback_timer);/* you normal work */
}-xtang
Chris McKillop <> cdm@qnx.com> > wrote:
If you are doing this within io-net you will probably need to use the
SIGEV_SIGNAL_THREAD() to ensure that the signal is sent to a specific
thread so that io-net’s signal thread doesn’t handle the signal behind
your back.chris
Sreekanth <> nospam@nospam.com> > wrote:
I used the following.
alarm(x);
signal(SIGALRM,myfunc);
This does not seem to work.One more thing worth mentioning, It is not a
independent application.It is part of io-net process(A filter more
precisely).Sreekanth
“Chris McKillop” <> cdm@qnx.com> > wrote in message
news:amqve3$j3s$> 1@nntp.qnx.com> …
Yes, that is what I told you to do. Setup a signal handler
(signal()),
setup your sigevent structure (SIGEV_SIGNAL()) and then create your
timer
(timer_create()).chris
Sreekanth <> nospam@nospam.com> > wrote:
Probably I didn’t make it clear.I need that my function be called
once
the
timer hits.I don’t want to create another thread to wait for the
message(or
pulse).
I need something like this…
create_timer(TimerID,callback,…);
void callback(void *data) {printf(“got the timer”);
return;
}
Now is this kind of API available?Thanks
Sreekanth“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:amqqub$dmq$> 1@nntp.qnx.com> …
Chris McKillop <> cdm@qnx.com> > wrote:
The timer_*() API on QNX will do this for you. You want to setup
the
sigevent struct to fire a signal instead of a pulse. You use the
signal()
API to setup a handler and the SIGEV_SIGNAL() to setup the
sigevent
structure.Or, of cause, you using pulse, and dispather, have pulse code
generated by pulse_attach().Then when timeout, a pulse will send to you, and the function
pulse_attach() will be called.-xtang
Sreekanth <> nospam@nospam.com> > wrote:
Is it possible in qnx to start a timer with a callback function
instead
of
message handler? i need something like
CreateTimer(timer_id,callback).Where
after the timer duration the function callback is called with an
argument.All i see now is to get the timer to send a message. I
know
something like that is possible in Windows.I didn’t see any API
in
documentation in QNX.Any help is greatly appreciated.
Sreekanth
\Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I
get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/
\