Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
1) Send a signal to the interrupted thread, and
2) Stop the execution of the interrupted thread (the thread must be descheduled after the interrupt returns)
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.
Quote:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.