When does do_signal() method avoid signal processing?
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.
When does do_signal() method avoid signal processing?
Hi,
I do have questions on the following code from the do_signal method defined in the file arch/i386/kernel/signal.c i.e.
/*
* We want the common case to go fast, which
* is why we may in certain cases get here from
* kernel mode. Just return without doing anything
* if so.
*/
if ((regs->xcs & 3) != 3)
return 1;
If I understand this code then it looks like kernel avoids signal processing from nested interrupts.
Is it true?
1) What's your kernel version?
I am using 2.6.9 kernel.
2) When I say 'kernel avoids signal processing from nested interrupts', I mean that returing from nested interrupts. It like
When one interrput handler is executing, another interrupt can occur and later will complete its execution before the former one.
Lets say an interrupt occur when process is executing in User Mode, it causes the process to switch to Kernel Mode and therefore the regs->xcs = 3, Am I right?
And lets say another interrupt occurs while executing the first interrupt handler, it causes the regs->xcs = 0, right? and while returning from latest handler, it calls the do_signal to process the signals but it doesn't process signals because regs->xcs == 0. And when the first interrupt handler calls do_signal while returning from the interrupt handler, it does process the signals because regs->xcs == 3.
it's an interesting question.
i'm thinking out loud because it's so complex.
signals cause interrupts too ! Oh My !
so interrupts calling signal() cause this recursive condition.
interrupts run in a kind of special interrupt context.
for one thing the original context might have faulted.
but it's fast it's not like context switching where you go to scheduling and like that.
lets say a non maskable interrupt happens.
system look to the interrupt pointer table and get the pointer to the interrupt handler memory space.
it hasn't really done context switching but it rather just goes to the system portion of the current stack and is then in kernel address space.
ok so now while the handler is executing another interrupt happens with higher priority.
so now the new interrupt could be handled in a context switch (new stack).
if it has lower priority it would put on hold till the first one returns then processed.
BUT if the register is set to 0 like you said then the signal isn't handled at all
until after the system restarts back in userspace.
i think it's the only really safe way to do it.
this avoids all the nutty conditions
when this could get all screwed up.
pending signal flags don't get cleared and whatnot when the reset to user space takes place.
in other words the state that got saved might not be the right/current state.
but this conveniently avoids the whole issue.
i think ? the whole thing is soooooo confusing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.