LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-18-2011, 03:04 AM   #1
pmehtal
LQ Newbie
 
Registered: Sep 2011
Posts: 12
Blog Entries: 1

Rep: Reputation: Disabled
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?

Thanks,
Pankaj
 
Old 10-19-2011, 02:28 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
What's your kernel version?
 
Old 10-19-2011, 10:23 PM   #3
gary185
Member
 
Registered: Jul 2011
Posts: 113

Rep: Reputation: Disabled
it's not even nested interupts but interrupt handlers altogether.

signals are only processed if they are going to return in user space.

this is just to catch some kind of a mistake yes ?

it might be like you said something funky and nested or recursive is going on
an interruptable interrupt handler ? but not necessarily.
 
Old 10-20-2011, 01:18 AM   #4
pmehtal
LQ Newbie
 
Registered: Sep 2011
Posts: 12

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi,

Thanks for your replies.

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.

Thanks,
Pankaj
 
Old 10-20-2011, 02:41 PM   #5
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
Just like comment, it protects that the function is invoked from kernel space.
 
Old 10-20-2011, 05:10 PM   #6
gary185
Member
 
Registered: Jul 2011
Posts: 113

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
avoid the defunc without using signal(SIGCHLD, SIG_IGN) nagendrar Programming 8 04-06-2009 11:21 AM
avoid defunc without using signal(SIGCHLD, SIG_IGN) in C++ nagendrar Programming 2 04-06-2009 03:02 AM
A faster batch processing method Rick069 Linux - Software 1 06-25-2007 11:23 PM
Signal processing programming in Linux naveenhifi Linux - Software 3 12-20-2003 04:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration