Skip to contentSkip to conversation

Signals

Xenomai-help Kent Borg 2 participants 4 messages Jan 18, 2006 – Jan 25, 2006

lore
Share & tools
lore

Kent Borg

author
#0 lore raw

Thanks for the news that gdb should just work.

Now I am wondering about signals. I want to be able to send a regular Linux signal to a userland realtime process. Do I use the regular signal() to install a signal handler? When would I use rt_task_catch() and rt_task_notify()?

What about multiple threads? I have 2 threads running. It seems that the thread that called signal() is the one landing in the handler routine. I would like to set some flags for the second thread to see, so it can cleanup things before quiting, but it seems that my second thread isn't running after I send the signal. I also think I am corrupting something, because if I set up a loop that launches and kills my program, my machine freezes up after a dozen cycles. I commented out most of my guts and it still freezes up.

Thanks,

-kb

#1 lore raw
Quoted 6 lines · Kent Borg

Thanks for the news that gdb should just work.

Now I am wondering about signals. I want to be able to send a regular Linux signal to a userland realtime process. Do I use the regular signal() to install a signal handler? When would I use rt_task_catch() and rt_task_notify()?

Those function are - in contrast to what to doc states - not yet available in userspace. So far Xenomai is lacking the infrastructure to deliver hard-RT signals to userspace threads, only the Linux signals are passed as usual.

Quoted 9 lines

What about multiple threads? I have 2 threads running. It seems that the thread that called signal() is the one landing in the handler routine. I would like to set some flags for the second thread to see, so it can cleanup things before quiting, but it seems that my second thread isn't running after I send the signal. I also think I am corrupting something, because if I set up a loop that launches and kills my program, my machine freezes up after a dozen cycles. I commented out most of my guts and it still freezes up.

Signals in multithreaded applications are tricky in general, even without Xenomai. You may try to play with pthread_kill and pthread_sigmask to control which thread receives a specific signal.

When the signal receiver is a Xenomai thread, the usual things happen:
blocking on RT-resources is cleared, the thread is migrated to secondary mode, and the signal handler is invoked as one expects.

Jan

author
#2 lore raw
Quoted 4 lines · Jan Kiszka
Quoted 1 line

rt_task_catch() and rt_task_notify()?

Those function are - in contrast to what to doc states - not yet available in userspace.

No wonder information on them is so sparse.

Quoted 3 lines

So far Xenomai is lacking the infrastructure to
deliver hard-RT signals to userspace threads, only the Linux signals are passed as usual.

But they are passed, that is good.

Quoted 3 lines

Signals in multithreaded applications are tricky in general, even without Xenomai. You may try to play with pthread_kill and pthread_sigmask to control which thread receives a specific signal.

I have a very simple architecture, one thread is launched by regular means, is launches the RT thread. It is the parent thread that registers for the signal and (I think!) it is the one that gets the interrupt.

Quoted 3 lines

When the signal receiver is a Xenomai thread, the usual things happen:
blocking on RT-resources is cleared, the thread is migrated to secondary mode, and the signal handler is invoked as one expects.

Very interesting. It sounds like Xenomai is doing cleanup I was trying to do by hand. Maybe that is why I crapped the kernel, I am cleaning up stuff that doesn't exist anymore. Should I deallocate my RT fifos?

Thanks,

-kb

#3 lore raw
Quoted 13 lines · Kent Borg
Quoted 3 lines · Jan Kiszka
Quoted 1 line

rt_task_catch() and rt_task_notify()?

Those function are - in contrast to what to doc states - not yet available in userspace.

No wonder information on them is so sparse.

Quoted 3 lines

So far Xenomai is lacking the infrastructure to
deliver hard-RT signals to userspace threads, only the Linux signals are passed as usual.

But they are passed, that is good.

Quoted 8 lines
Quoted 3 lines

Signals in multithreaded applications are tricky in general, even without Xenomai. You may try to play with pthread_kill and pthread_sigmask to control which thread receives a specific signal.

I have a very simple architecture, one thread is launched by regular means, is launches the RT thread. It is the parent thread that registers for the signal and (I think!) it is the one that gets the interrupt.

Try printing pthread_self in your signal handler to be sure.

Quoted 10 lines
Quoted 4 lines

When the signal receiver is a Xenomai thread, the usual things happen:
blocking on RT-resources is cleared, the thread is migrated to secondary mode, and the signal handler is invoked as one expects.

Very interesting. It sounds like Xenomai is doing cleanup I was trying to do by hand. Maybe that is why I crapped the kernel, I am cleaning up stuff that doesn't exist anymore. Should I deallocate my RT fifos?

No, the native skin does not perform much automatic cleanup, especially not for userspace objects. If I'm not overseeing some detail, the only thing that gets cleaned up automatically on process termination are tasks. Even on unloading the native skin module (when being a module at all anymore), no forgotten userspace object gets deleted. The posix skin does such cleanup, but only globally, on module unload.

So the rule is the cleanup everything as long as you are able to (i.e. your application didn't die due to some bug etc.)

Jan