Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
What kind of signal?
And what should happen if there is no interrupted thread, or if you interrupted a kernel thread?
A POSIX signal. There will be checks if the interrupted thread is not a target.
That might be possible, but this isn't something that should be done outside the scheduler itself.
What are you trying to accomplish?
Actually, I was very unclear. The behavior that I want is that the interrupted thread (assume it's a target) should not continue normal execution before handling the signal. I believe that signal handlers are only called when the thread is about to be rescheduled? If it's an interrupt, I don't want the interrupt to return, then the thread executes without realizing it has received a signal, and have the signal be received after the thread is rescheduled, which may happen who-knows-when.
Basically, the next code that the thread executes has to be the signal handler, not the program code.
As far as I know, this is the default behaviour, even if the target is running on another processor.
Does this work even if called from interrupt context?
A more general question would be, does the interrupt handler immediately return control to the interrupted thread as if nothing had happened, or does it invoke the scheduler first? It seems that this might not work if control was immediately returned to the interrupted thread.
My intuitive thought is that you capture the interrupt in the (by any other name) "top half" and then schedule the (call it what you like) "bottom half," in which you can post a signal to another process or thread... you're no longer in an interrupts-restricted context. The "bottom half" will be resolved before any user-land processes run again.
However, having said that, you must also consider the multi-CPU case. I can envision that, once in a blue moon, the target task might be running on a different CPU that, o'course, didn't get the interrupt. So you might have to be content with "the target process handles the signal 'very, very promptly.'" That's usually the way of such things.