SIGEV_SIGNAL_THREAD

As stated in on-line help:

“SIGEV_SIGNAL_THREAD send a signal to a specific thread”.

The initialization macro has only “signal”, “code” and “value” as
parameters.
How can be specified the thread ID?

Thanks for any help.

I think SIGEV_SIGNAL_THREAD will start your signal handler as a separate
thread.

Maurizio Rossi wrote:

As stated in on-line help:

“SIGEV_SIGNAL_THREAD send a signal to a specific thread”.

The initialization macro has only “signal”, “code” and “value” as
parameters.
How can be specified the thread ID?

Thanks for any help.

Maurizio Rossi <mrossi@system-group.it> wrote:

As stated in on-line help:

“SIGEV_SIGNAL_THREAD send a signal to a specific thread”.

The initialization macro has only “signal”, “code” and “value” as
parameters.
How can be specified the thread ID?

There are two ways of getting an event delivered: MsgDeliverEvent() and
the return from an interrupt handler. In the first case, the thread is
one that originally did the MsgSend() (as identified by the rcvid parameter).
In the second, the signal is delivered to the thread that did the
InterruptAttach[Event].


Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8

Igor Kovalenko <Igor.Kovalenko@motorola.com> wrote:

I think SIGEV_SIGNAL_THREAD will start your signal handler as a separate
thread.

I think you’re thinking of SIGEV_THREAD - that starts a new thread
with the passed in function pointer. That’s the only one that starts
a new thread.

BTW, this is a bit heavy handed for event delivery, so people, don’t go
COOL” and start using SIGEV_THREAD for everything. Thank you, and we
now return you to your regularly scheduled programming :slight_smile:.


Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8

Brian Stecher <bstecher@qnx.com> wrote in message
news:8sphp4$cvt$2@nntp.qnx.com

Maurizio Rossi <> mrossi@system-group.it> > wrote:
As stated in on-line help:

“SIGEV_SIGNAL_THREAD send a signal to a specific thread”.

The initialization macro has only “signal”, “code” and “value” as
parameters.
How can be specified the thread ID?

There are two ways of getting an event delivered: MsgDeliverEvent() and
the return from an interrupt handler. In the first case, the thread is
one that originally did the MsgSend() (as identified by the rcvid
parameter).
In the second, the signal is delivered to the thread that did the
InterruptAttach[Event].


Brian Stecher (> bstecher@qnx.com> ) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M
1W8

Thanks Mr. Stecher for your reply.

My SIGEV_SIGNAL_THREAD use is:

void *mythread(void *p)
{
struct sigevent myevent;
timer_t mytimer;
struct itimerspec timvalue;
sigset_t mysigset;
siginfo_t mysiginfo;

/* SIGRTMAX+3 is always blocked, it is ok for “syncronous notification” */
sigemptyset(&mysigset);
sigaddset(&mysigset, SIGRTMAX+3);
SIGEV_SIGNAL_THREAD_INIT(&myevent,SIGRTMAX+3,0,0);
timer_create(CLOCK_REALTIME,&myevent,&mytimer);

timvalue.it_value.tv_sec = 0;
timvalue.it_value.tv_nsec = (int)p * 1000000;
timvalue.it_interval.tv_sec = 0;
timvalue.it_interval.tv_nsec = (int)p * 1000000;
timer_settime(mytimer,0,&timvalue,NULL);

for (;:wink:
{
SignalWaitinfo(&mysigset,&mysiginfo);
// thread job
}

}

int main(int argc, char **argv)
{

ThreadCreate(0,mythread,(void*)10,NULL);
ThreadCreate(0,mythread,(void*)50,NULL);
ThreadCreate(0,mythread,(void*)100,NULL);

}

Is this stupid and/or orrible?

Maurizio Rossi <mrossi@system-group.it> wrote:

Thanks Mr. Stecher for your reply.

My SIGEV_SIGNAL_THREAD use is:

Is this stupid and/or orrible?

Doh! I knew I was going to forget a way for sigevents to happen. Obviously
they can be used with timer_create/timer_timeout. In those cases, the
thread getting the signal will be the thread making those calls. I
didn’t try filling out and running your code, but it looks fine to me.

\

Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8

Brian Stecher <bstecher@qnx.com> wrote in message
news:8t1ftm$1m4$1@nntp.qnx.com

Maurizio Rossi <> mrossi@system-group.it> > wrote:

Thanks Mr. Stecher for your reply.

My SIGEV_SIGNAL_THREAD use is:

Is this stupid and/or orrible?

Doh! I knew I was going to forget a way for sigevents to happen. Obviously
they can be used with timer_create/timer_timeout. In those cases, the
thread getting the signal will be the thread making those calls. I
didn’t try filling out and running your code, but it looks fine to me.

\

Brian Stecher (> bstecher@qnx.com> ) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M
1W8

Thanks Mr. Stecher for your reply.

Can I suggest to expand documentation about “signals for syncronous
notification”? : System architecture, Programmer Reference and
also “Getting started with Neutrino V2” by Mr.Krten are scarce on such
topic.

I think “signals” used in this way are great if no channel/connections are
required.

Best regards.