Why can"t we sleep in an ISR?
Why can"t we sleep in an ISR?
am 14.05.2007 08:37:12 von Learning Linux
I have a very basic doubt here ... what makes it impossible to sleep
in an ISR? I mean, I know that the kernel preemption is disabled and
the kernel will panic, but I could not understand why?
TIA,
LL
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 14.05.2007 09:10:14 von pradeep singh
------=_Part_143789_22170823.1179126614873
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/14/07, Learning Linux wrote:
>
> I have a very basic doubt here ... what makes it impossible to sleep
> in an ISR? I mean, I know that the kernel preemption is disabled and
> the kernel will panic, but I could not understand why?
Because the interrupt which you are serving in the ISR has been masked
to avoid preemption(
true for maskable inetrrupts ).Any locks you are holding in ISR are now with
you solely. So, if you try to sleep you take the locks
you untill you are rescheduled and complete. This may lead to a
deadlock for the lock resource.
Thus to avoid this, kernel developers disable preemption and also on every
schedule check if you are *in_interrupt*, if you are, you are probably doing
something really bad.So its better to panic in such case.
This is my naive understanding.
Please CMIIW.
Thanks
TIA,
>
> LL
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>
--
play the game
------=_Part_143789_22170823.1179126614873
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/14/07, Learning Linux <> wrote:
I have a very basic doubt here ... what makes it impossible to sleep
in an ISR? I mean, I know that the kernel preemption is disabled and
the kernel will panic, but I could not understand why?
Because the interrupt which you are serving in the ISR has been masked to avoid preemption( true for maskable inetrrupts ).Any locks you are holding in ISR are now with you solely. So, if you try to sleep you take the locks you untill you are rescheduled and complete. This may lead to a deadlock for the lock resource.
Thus to avoid this, kernel developers disable preemption and also on every schedule check if you are *in_interrupt*, if you are, you are probably doing something really bad.So its better to panic in such case.
This is my naive understanding.
Please CMIIW.
Thanks
TIA,
LL
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to
Please read the FAQ at
http://kernelnewbies.org/FAQ
--
play the game
------=_Part_143789_22170823.1179126614873--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Why can"t we sleep in an ISR?
am 14.05.2007 09:16:26 von Learning Linux
> > I have a very basic doubt here ... what makes it impossible to sleep
> > in an ISR? I mean, I know that the kernel preemption is disabled and
> > the kernel will panic, but I could not understand why?
>
> Because the interrupt which you are serving in the
> ISR has been masked to avoid preemption(
> true for maskable inetrrupts ).Any locks you are holding in ISR are now with
> you solely. So, if you try to sleep you take the locks you untill you are
> rescheduled and complete. This may lead to
> a deadlock for the lock resource.
Ok, but how about an ISR, that does not take any locks? Why can't we
sleep in SUCH an ISR?
AFAIK, taking a lock disables kernel preemption, and hence it is not
allowed to sleep. So I think my question would boil down to why is
sleeping not allowed when the kernel preemption is disabled.
LL
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 14.05.2007 14:25:17 von Helge Hafting
Learning Linux wrote:
> I have a very basic doubt here ... what makes it impossible to sleep
> in an ISR? I mean, I know that the kernel preemption is disabled and
> the kernel will panic, but I could not understand why?
First: an ISR is meant to be very quick. It is supposed to do only a
minimum of work needed to service the interrupt, then exit.
This is important, as other interrupts might be blocked during your ISR.
Sleeping is out of question, even a long-running loop in no-no.
Second: You don't ever need to sleep in an ISR anyway.
Complicated work that might take time or might need to sleep
is not supposed to be in an ISR. If you think you have a need,
tell us what you're up to and hopefully someone will explain
how do do things properly.
When an interrupt happens that needs complicated servicing, the
ISR don't do the whole job. It just acknowledges the interrupt,
perhaps does a few things with the device in question, then it
exits. It leaves the rest of the work for a bottom half or kernel
thread or something like that. Kernel threads may sleep . . .
Helge Hafting
Re: Why can"t we sleep in an ISR?
am 14.05.2007 14:52:52 von pradeep singh
------=_Part_147142_10372041.1179147172409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/14/07, Helge Hafting wrote:
>
> Learning Linux wrote:
> > I have a very basic doubt here ... what makes it impossible to sleep
> > in an ISR? I mean, I know that the kernel preemption is disabled and
> > the kernel will panic, but I could not understand why?
> First: an ISR is meant to be very quick. It is supposed to do only a
> minimum of work needed to service the interrupt, then exit.
> This is important, as other interrupts might be blocked during your ISR.
> Sleeping is out of question, even a long-running loop in no-no.
>
> Second: You don't ever need to sleep in an ISR anyway.
> Complicated work that might take time or might need to sleep
> is not supposed to be in an ISR. If you think you have a need,
> tell us what you're up to and hopefully someone will explain
> how do do things properly.
>
> When an interrupt happens that needs complicated servicing, the
> ISR don't do the whole job. It just acknowledges the interrupt,
> perhaps does a few things with the device in question, then it
> exits. It leaves the rest of the work for a bottom half or kernel
> thread or something like that. Kernel threads may sleep . . .
Helge, i think the Original poster wants to know why *exactly*
cannot you sleep?
What prevents me from sleeping?
What is this complicated processing which force an ISR not to sleep?
Thanks
Helge Hafting
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>
--
play the game
------=_Part_147142_10372041.1179147172409
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/14/07, Helge Hafting <> wrote:
Learning Linux wrote:
> I have a very basic doubt here ... what makes it impossible to sleep
> in an ISR? I mean, I know that the kernel preemption is disabled and
> the kernel will panic, but I could not understand why?
First: an ISR is meant to be very quick. It is supposed to do only a
minimum of work needed to service the interrupt, then exit.
This is important, as other interrupts might be blocked during your ISR.
Sleeping is out of question, even a long-running loop in no-no.
Second: You don't ever need to sleep in an ISR anyway.
Complicated work that might take time or might need to sleep
is not supposed to be in an ISR. If you think you have a need,
tell us what you're up to and hopefully someone will explain
how do do things properly.
When an interrupt happens that needs complicated servicing, the
ISR don't do the whole job. It just acknowledges the interrupt,
perhaps does a few things with the device in question, then it
exits. It leaves the rest of the work for a bottom half or kernel
thread or something like that. Kernel threads may sleep . . .
Helge, i think the Original poster wants to know why *exactly* cannot you sleep?
What prevents me from sleeping?
What is this complicated processing which force an ISR not to sleep?
Thanks
Helge Hafting
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to
Please read the FAQ at
http://kernelnewbies.org/FAQ
--
play the game
------=_Part_147142_10372041.1179147172409--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Why can"t we sleep in an ISR?
am 14.05.2007 15:36:24 von Dong Feng
My understanding is as follows.
Whenever the kernel code sleeps, it means the latest process running
in user space will have to wait for the event on which the kernel code
sleeps.
It makes sense for an exception handler to sleep because an exception
handler always serves the latest process running in user space. So a
process can complain nothing for it having to wait for the event on
which the exception handler in its own context sleeps.
It makes no sense for an ISR to sleep because an ISR does not
necessarily serve the latest process (that is, the interrupted
process). It makes no sense having a process wait for the event having
nothing to do with it.
I could be wrong, so please correct me if the understanding is not right.
2007/5/14, pradeep singh <2500.pradeep@gmail.com>:
>
>
> On 5/14/07, Helge Hafting wrote:
> > Learning Linux wrote:
> > > I have a very basic doubt here ... what makes it impossible to sleep
> > > in an ISR? I mean, I know that the kernel preemption is disabled and
> > > the kernel will panic, but I could not understand why?
> > First: an ISR is meant to be very quick. It is supposed to do only a
> > minimum of work needed to service the interrupt, then exit.
> > This is important, as other interrupts might be blocked during your ISR.
> > Sleeping is out of question, even a long-running loop in no-no.
> >
> > Second: You don't ever need to sleep in an ISR anyway.
> > Complicated work that might take time or might need to sleep
> > is not supposed to be in an ISR. If you think you have a need,
> > tell us what you're up to and hopefully someone will explain
> > how do do things properly.
> >
> > When an interrupt happens that needs complicated servicing, the
> > ISR don't do the whole job. It just acknowledges the interrupt,
> > perhaps does a few things with the device in question, then it
> > exits. It leaves the rest of the work for a bottom half or kernel
> > thread or something like that. Kernel threads may sleep . . .
>
> Helge, i think the Original poster wants to know why
> *exactly* cannot you sleep? What prevents me from
> sleeping?
>
> What is this complicated processing which force an ISR not to sleep?
>
> Thanks
>
> > Helge Hafting
> >
> > --
> > To unsubscribe from this list: send an email with
> > "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> > Please read the FAQ at http://kernelnewbies.org/FAQ
> >
> >
>
>
>
> --
> play the game
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 14.05.2007 17:22:18 von linux
Sleeping in an ISR is not fundamentally impossible - I could design
a multitasker that permitted it - but has significant problems, and
most multitaskers, including Linux, forbid it.
The first problem is the scheduler. "Sleeping" is actually a call
into the scheduler to choose another process to run. There are times -
so-called critical sections - when the scheduler can't be called.
If an interrupt can call the scheduler, then every criticial section
has to disable interrupts. Otherwise, an interrupt might arrive and
end up calling the scheduler. This increases interrupt latency.
If interrupts are forbidden to sleep, then there's no need to
disable interrupts in critical sections, so interrupts can be responded
to faster. Most multitaskers find this worth the price.
The second problem is shared interrupts. You want to sleep until something
happens. The processor hears about that event via an interrupt. Inside
an ISR, interrupts are disabled.
You have to somehow enable the interrupt that will wake up the sleeping
ISR without enabling the interrupt that the ISR is in the middle of handling
(or the handler will start a second time and make a mess).
This is complicated and prone to error. And, in the case of shared interrupts
(as allowed by PCI), it's possible that the the interrupt you need
to wait for is exactly the same interrupt as what you're in the middle
of handling. So it might be impossible!
The third problem is that you're obviously increasing the latency of the
interrupt whose handler you're sleeping in.
Finally, if you're even *thinking* of wanting to sleep in an ISR,
you probably have a deadlock waiting to happen.
Re: Why can"t we sleep in an ISR?
am 14.05.2007 17:24:29 von Bahadir Balban
On 5/14/07, Learning Linux wrote:
> Ok, but how about an ISR, that does not take any locks? Why can't we
> sleep in SUCH an ISR?
> LL
> -
The killer reason why you can't sleep in an interrupt is because an
interrupt is not associated with any context in the first place. What
is a context, then? It is the state information for a process. This
includes the kernel and userspace stack pointers, the register set,
and the page tables for that process. The scheduler has access to all
this information, to preempt one process and run another. Contrary to
this, an interrupt, depending on the version of your kernel and arch,
uses a separate irq stack or the kernel stack of the interrupted
process. An irq is not a context but merely a temporary execution to
be concluded asap.
Hope this helps,
Bahadir
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 14.05.2007 17:55:10 von Rik van Riel
linux@horizon.com wrote:
> Sleeping in an ISR is not fundamentally impossible - I could design
> a multitasker that permitted it - but has significant problems, and
> most multitaskers, including Linux, forbid it.
You could design a system in which most ISRs can sleep,
but even then you'll probably need to make exceptions.
For example, the timer interrupt tends to drive the
scheduler. This means the timer interrupt cannot go
to sleep and expect the scheduler to wake it up at
some point in the future - since there will be no new
timer interrupts to drive the scheduler.
This precludes the timer interrupt from taking certain
sleeping locks, even on a system where interrupts can
sleep (not Linux).
Interrupts will always have some limitations, under
any OS design.
--
All Rights Reversed
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 14.05.2007 17:56:15 von Dong Feng
I agree that the reason an interrupt can not sleep is because an
interrupt is not associated with any context. But I do not agree that
it is specifically because the scheduler can not *resume* the context.
In early version, the ISR always borrow the stack of the currently
running process, so if the kernel design had allowed ISR sleep, it
would automatically be able to implement the context switch naturally.
But ISR sleep has been forbidden from the very beginning.
The reason why kernel design does not allow ISR sleep is because a
process should not be forced to wait for a event that irrelative to
itself. When an exception handler sleep, the event it sleeps on is
always in some sense related to the process incurring that exception.
But if an ISR was allowed to sleep, the event it sleeps on would have
nothing to do with the process being interrupted.
So my understanding is, the forbidden of ISR sleep is not because of
the difficulty to resume context, but because a process should not
wait for irrelative event.
2007/5/14, Bahadir Balban :
> On 5/14/07, Learning Linux wrote:
> > Ok, but how about an ISR, that does not take any locks? Why can't we
> > sleep in SUCH an ISR?
> > LL
> > -
>
> The killer reason why you can't sleep in an interrupt is because an
> interrupt is not associated with any context in the first place. What
> is a context, then? It is the state information for a process. This
> includes the kernel and userspace stack pointers, the register set,
> and the page tables for that process. The scheduler has access to all
> this information, to preempt one process and run another. Contrary to
> this, an interrupt, depending on the version of your kernel and arch,
> uses a separate irq stack or the kernel stack of the interrupted
> process. An irq is not a context but merely a temporary execution to
> be concluded asap.
>
> Hope this helps,
> Bahadir
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 15.05.2007 07:17:54 von pradeep singh
------=_Part_157389_2355371.1179206274153
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/14/07, Bahadir Balban wrote:
>
> On 5/14/07, Learning Linux wrote:
> > Ok, but how about an ISR, that does not take any locks? Why can't we
> > sleep in SUCH an ISR?
> > LL
> > -
>
> The killer reason why you can't sleep in an interrupt is because an
> interrupt is not associated with any context in the first place.
good enough, but i have a query regarding this then.
On a 8K kernel stack system, doesn't interrupts share the stack associated
with the current process which was interrupted?
Doesn't interrupt steals the CPU slice time allocated to the running process
to run?
Doesn't it run in current process's context ?
What am i missing here?
Thanks
~psr
What
> is a context, then? It is the state information for a process. This
> includes the kernel and userspace stack pointers, the register set,
> and the page tables for that process. The scheduler has access to all
> this information, to preempt one process and run another. Contrary to
> this, an interrupt, depending on the version of your kernel and arch,
> uses a separate irq stack or the kernel stack of the interrupted
> process. An irq is not a context but merely a temporary execution to
> be concluded asap.
>
> Hope this helps,
> Bahadir
>
--
play the game
------=_Part_157389_2355371.1179206274153
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/14/07, Bahadir Balban <> wrote:
On 5/14/07, Learning Linux <> wrote:
> Ok, but how about an ISR, that does not take any locks? Why can't we
> sleep in SUCH an ISR?
> LL
> -
The killer reason why you can't sleep in an interrupt is because an
interrupt is not associated with any context in the first place.
good enough, but i have a query regarding this then.
On a 8K kernel stack system, doesn't interrupts share the stack associated with the current process which was interrupted?
Doesn't interrupt steals the CPU slice time allocated to the running process to run?
Doesn't it run in current process's context ?
What am i missing here?
Thanks
~psr
What
is a context, then? It is the state information for a process. This
includes the kernel and userspace stack pointers, the register set,
and the page tables for that process. The scheduler has access to all
this information, to preempt one process and run another. Contrary to
this, an interrupt, depending on the version of your kernel and arch,
uses a separate irq stack or the kernel stack of the interrupted
process. An irq is not a context but merely a temporary execution to
be concluded asap.
Hope this helps,
Bahadir
--
play the game
------=_Part_157389_2355371.1179206274153--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Why can"t we sleep in an ISR?
am 15.05.2007 08:45:43 von Dong Feng
>
> good enough, but i have a query regarding this then.
> On a 8K kernel stack system, doesn't interrupts share the stack associated
> with the current process which was interrupted?
Yes, I think so.
> Doesn't interrupt steals the CPU slice time allocated to the running process
> to run?
I don't think so but I am not sure.
> Doesn't it run in current process's context ?
>
No. I think the concept of process context is a higher-level logical
concept. Though the interrupt share stack with the interrupted
process, in my opinion it logically does not share the context with
the process.
> What am i missing here?
>
> Thanks
> ~psr
>
But I do not see the exact relationship between your specific queries
and the original question. Could you elaborate?
Re: Why can"t we sleep in an ISR?
am 15.05.2007 09:10:12 von pradeep singh
------=_Part_158341_13137435.1179213012858
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/15/07, Dong Feng wrote:
>
> >
> > good enough, but i have a query regarding this then.
> > On a 8K kernel stack system, doesn't interrupts share the stack
> associated
> > with the current process which was interrupted?
>
> Yes, I think so.
>
> Yes it does.
> > Doesn't interrupt steals the CPU slice time allocated to the running
> process
> > to run?
>
> I don't think so but I am not sure.
Aliter, i think so.How
can an interrupt's execution time go unaccounted then?
I guess it does not, only the current processes running time is accounted
for.
Thoughts?
> Doesn't it run in current process's context ?
> >
>
> No. I think the concept of process context is a higher-level logical
> concept. Though the interrupt share stack with the interrupted
> process, in my opinion it logically does not share the context with
> the process.
Yes, you are right as i can infer. thats why ISRs are special kernel
control paths.
But the poster asked, why can't we make ISRs to share context with the
interrupted process if
it not holding any locks? This is rather a desing issues IMO rather
than imlementation, isnt it?
I guess even if it is possible, it would over complicate the handler code.
Better trying to keep it simple i guess. Please CMIIW
[snip]
>
> But I do not see the exact relationship between your specific queries
> and the original question. Could you elaborate?
My query here was related to your previous reply.Just wanted to pit some doubts
as raised by the orirignal poster.That's it.
Thank you
~psr
--
play the game
------=_Part_158341_13137435.1179213012858
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/15/07, Dong Feng <> wrote:
>
> good enough, but i have a query regarding this then.
> On a 8K kernel stack system, doesn't interrupts share the stack associated
> with the current process which was interrupted?
Yes, I think so.
Yes it does.
> Doesn't interrupt steals the CPU slice time allocated to the running process
> to run?
I don't think so but I am not sure.
Aliter, i think so.How can an interrupt's execution time go unaccounted then?
I guess it does not, only the current processes running time is accounted for.
Thoughts?
> Doesn't it run in current process's context ?
>
No. I think the concept of process context is a higher-level logical
concept. Though the interrupt share stack with the interrupted
process, in my opinion it logically does not share the context with
the process.
Yes, you are right as i can infer. thats why ISRs are special kernel control paths.
But the poster asked, why can't we make ISRs to share context with the interrupted process if
it not holding any locks? This is rather a desing issues IMO rather than imlementation, isnt it?
I guess even if it is possible, it would over complicate the handler code. Better trying to keep it simple i guess. Please CMIIW
[snip]
But I do not see the exact relationship between your specific queries
and the original question. Could you elaborate?
My query here was related to your previous reply.Just wanted to pit some doubts as raised by the orirignal
poster.That's it.
Thank you
~psr
--
play the game
------=_Part_158341_13137435.1179213012858--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Why can"t we sleep in an ISR?
am 15.05.2007 09:28:06 von Dong Feng
> >
> > I don't think so but I am not sure.
>
> Aliter, i think so.How can an interrupt's execution time go
> unaccounted then?
> I guess it does not, only the current processes running
> time is accounted for.
> Thoughts?
>
The interrupt handler's execution time will definitely defer the
execution of the process, but I think it does not steal the process's
time slice (the time_slice field not subtracted).
> > > Doesn't it run in current process's context ?
> > >
> >
> > No. I think the concept of process context is a higher-level logical
> > concept. Though the interrupt share stack with the interrupted
> > process, in my opinion it logically does not share the context with
> > the process.
>
> Yes, you are right as i can infer. thats why ISRs
> are special kernel control paths.
> But the poster asked, why can't we make ISRs to
> share context with the interrupted process
> if
> it not holding any locks? This is rather a desing issues
> IMO rather than imlementation, isnt it?
>
> I guess even if it is possible, it would over complicate the handler code.
> Better trying to keep it simple i guess. Please CMIIW
My understanding is, the ISR is in different context from the process
because of the definition of term *context*. In my opinion, to say two
code pieces running in the same context means that two pieces of code
has some logical relationship to meet a common objective. That's why I
said *context* is a higher-level logical concept. It's not a concept
defined in the level of hardware or code implementation, but instead
in the level of logical. I think, by its definition, it makes no sense
to say an ISR share context with the process interrupted by it because
an ISR just randomly interrupts a process, with no logical
relationship.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 15.05.2007 10:12:32 von pradeep singh
------=_Part_158813_5644331.1179216752720
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/15/07, Dong Feng wrote:
>
> > >
> > > I don't think so but I am not sure.
> >
> > Aliter, i think so.How can an interrupt's execution time go
> > unaccounted then?
> > I guess it does not, only the current processes running
> > time is accounted for.
> > Thoughts?
> >
>
> The interrupt handler's execution time will definitely defer the
> execution of the process, but I think it does not steal the process's
> time slice (the time_slice field not subtracted).
Ok, if i accept this, how does that explains this-
Following code snippet is from main schedule() function[kernel 2.6.20.1] -
now = sched_clock();
if(likely((long long)(now - prev->timestamp) < NS_MAX_SLEEP_AVG)) {
run_time = now - prev->timestamp;
/* blah blah */
} else
run_time = NS_MAX_SLEEP_AVG;
Now,
AFAIK runtime = now - prev->timestamp; will get you a value which (
prev->timestamp is *stamped* during previous
switching of the tasks) is difference of this previous stamp and now value.
Assuming before this schedule() an interrupt was served, then where did the
time spent in ISR accounting is adjusted? I guess this is the code, where
it is checking for a *possible* runtime to overshoot its stipulated
NS_MAX_SLEEP_AVG and resetting this. Isn't it?
And exactly why would that happen?
Perhaps because the process was about to expire its slice when somebody
barged in and stole its share and also overshot the stipulated time(may be
very less though).
Can you help me in clearing this?
> > > Doesn't it run in current process's context ?
> > > >
> > >
> > > No. I think the concept of process context is a higher-level logical
> > > concept. Though the interrupt share stack with the interrupted
> > > process, in my opinion it logically does not share the context with
> > > the process.
> >
> > Yes, you are right as i can infer. thats why ISRs
> > are special kernel control paths.
> > But the poster asked, why can't we make ISRs to
> > share context with the interrupted process
> > if
> > it not holding any locks? This is rather a desing issues
> > IMO rather than imlementation, isnt it?
> >
> > I guess even if it is possible, it would over complicate the handler
> code.
> > Better trying to keep it simple i guess. Please CMIIW
>
> My understanding is, the ISR is in different context from the process
> because of the definition of term *context*. In my opinion, to say two
> code pieces running in the same context means that two pieces of code
> has some logical relationship to meet a common objective. That's why I
> said *context* is a higher-level logical concept. It's not a concept
> defined in the level of hardware or code implementation, but instead
> in the level of logical. I think, by its definition, it makes no sense
> to say an ISR share context with the process interrupted by it because
> an ISR just randomly interrupts a process, with no logical
> relationship.
Right agreed.
Thanks
~psr
--
play the game
------=_Part_158813_5644331.1179216752720
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 5/15/07, Dong Feng <middle.fengdong@gmail.com
> wrote:
> >
> > I don't think so but I am not sure.
>
> Aliter, i think so.How can an interrupt's execution time go
> unaccounted then?
> I guess it does not, only the current processes running
> time is accounted for.
> Thoughts?
>
The interrupt handler's execution time will definitely defer the
execution of the process, but I think it does not steal the process's
time slice (the time_slice field not subtracted).
Ok, if i accept this, how does that explains this-
Following code snippet is from main schedule() function[kernel ] -
now = sched_clock();
if(likely((long long)(now - prev->timestamp) < NS_MAX_SLEEP_AVG)) {
run_time = now - prev->timestamp;
/* blah blah */
} else
run_time = NS_MAX_SLEEP_AVG;
Now, AFAIK runtime = now - prev->timestamp; will get you a value which ( prev->timestamp is *stamped* during previous switching of the tasks) is difference of this previous stamp and now value.
Assuming before this schedule() an interrupt was served, then where did the time spent in ISR accounting is adjusted? I guess this is the code, where it is checking for a *possible* runtime to overshoot its stipulated NS_MAX_SLEEP_AVG and resetting this. Isn't it?
And exactly why would that happen?
Perhaps because the process was about to expire its slice when somebody barged in and stole its share and also overshot the stipulated time(may be very less though).
Can you help me in clearing this?
> > > Doesn't it run in current process's context ?
> > >
> >
> > No. I think the concept of process context is a higher-level logical
> > concept. Though the interrupt share stack with the interrupted
> > process, in my opinion it logically does not share the context with
> > the process.
>
> Yes, you are right as i can infer. thats why ISRs
> are special kernel control paths.
> But the poster asked, why can't we make ISRs to
> share context with the interrupted process
> if
> it not holding any locks? This is rather a desing issues
> IMO rather than imlementation, isnt it?
>
> I guess even if it is possible, it would over complicate the handler code.
> Better trying to keep it simple i guess. Please CMIIW
My understanding is, the ISR is in different context from the process
because of the definition of term *context*. In my opinion, to say two
code pieces running in the same context means that two pieces of code
has some logical relationship to meet a common objective. That's why I
said *context* is a higher-level logical concept. It's not a concept
defined in the level of hardware or code implementation, but instead
in the level of logical. I think, by its definition, it makes no sense
to say an ISR share context with the process interrupted by it because
an ISR just randomly interrupts a process, with no logical
relationship.
Right agreed.
Thanks
~psr
--
play the game
------=_Part_158813_5644331.1179216752720--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Why can"t we sleep in an ISR?
am 15.05.2007 10:40:52 von Learning Linux
> The interrupt handler's execution time will definitely defer the
> execution of the process, but I think it does not steal the process's
> time slice (the time_slice field not subtracted).
It will definitely be substracted from the process's time slice.
Because the timeslice is substracted in timer interrupt, and does not
differenciate if the process is executing ISR or not.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 15.05.2007 10:58:02 von Dong Feng
Yes, you are right in this regard. An interrupt handler does steal the
time slice from the interrupted process.
So now I think it is considered an acceptable deviation in calculating
the process run time as well as determine process scheduling because
an ISR should take very short time to return, in part as a consequence
of the rule that ISR should not sleep.
2007/5/15, Learning Linux :
> > The interrupt handler's execution time will definitely defer the
> > execution of the process, but I think it does not steal the process's
> > time slice (the time_slice field not subtracted).
>
> It will definitely be substracted from the process's time slice.
> Because the timeslice is substracted in timer interrupt, and does not
> differenciate if the process is executing ISR or not.
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 15.05.2007 11:34:23 von rohit hooda
This is a multipart mime message
--Next_1179221663---0-202.54.124.237-1119
Content-type: text/plain;
charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
=0AOn Tue, 15 May 2007 pradeep singh wrote :=0A>On 5/14/07, Bahadir=
Balban wrote:=0A>>=0A>>On 5/14/07, Learning Lin=
ux wrote:=0A>> > Ok, but how about an ISR, that =
does not take any locks? Why can't we=0A>> > sleep in SUCH an ISR?=0A>> > L=
L=0A>> > -=0A>>=0A>>The killer reason why you can't sleep in an interrupt i=
s because an=0A>>interrupt is not associated with any context in the first =
place.=0A>=0A>=0A>good enough, but i have a query regarding this then.=0A>O=
n a 8K kernel stack system, doesn't interrupts share the stack associated=
=0A>with the current process which was interrupted?=0AYes, you are right.=
=0A>Doesn't interrupt steals the CPU slice time allocated to the running pr=
ocess=0A>to run?=0AYes=0A>Doesn't it run in current process's context ?=0AY=
ou got it worng here. It runs on behalf of the process, but in the current =
process's context. =0AFor interrupts we have a dirrerent context altogether=
..=0A>=0A>What am i missing here?=0AThere are two different contexts of exec=
ution=0AProcess context=0AInterrupt context=0A>=0A>Thanks=0A>~psr=0A>=0ATha=
nks,=0A-Rohit=0A>What=0A>>is a context, then? It is the state information f=
or a process. This=0A>>includes the kernel and userspace stack pointers, th=
e register set,=0A>>and the page tables for that process. The scheduler has=
access to all=0A>>this information, to preempt one process and run another=
.. Contrary to=0A>>this, an interrupt, depending on the version of your kern=
el and arch,=0A>>uses a separate irq stack or the kernel stack of the inter=
rupted=0A>>process. An irq is not a context but merely a temporary executio=
n to=0A>>be concluded asap.=0A>>=0A>>Hope this helps,=0A>>Bahadir=0A>>=0A>=
=0A>=0A>=0A>-- play the game=0A
--Next_1179221663---0-202.54.124.237-1119
Content-type: text/html;
charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
=0A
=0A
=0A
=0AOn Tue, 15 May 2007 pradeep singh wrote :=
=0A>On 5/14/07, Bahadir Balban <bahadir.balban@gmail.com> wrot=
e:
=0A>>
=0A>>On 5/14/07, Learning Linux <learninglinu=
x4@gmail.com> wrote:
=0A>> > Ok, but how about an ISR, that =
does not take any locks? Why can't we
=0A>> > sleep in SUCH an =
ISR?
=0A>> > LL
=0A>> > -
=0A>>
=0A>=
>The killer reason why you can't sleep in an interrupt is because an
=
=0A>>interrupt is not associated with any context in the first place.=
=0A>
=0A>
=0A>good enough, but i have a query regarding =
this then.
=0A>On a 8K kernel stack system, doesn't interrupts share =
the stack associated
=0A>with the current process which was interrupt=
ed?
=0AYes, you are right.
=0A>Doesn't interrupt steals the CPU sl=
ice time allocated to the running process
=0A>to run?
=0AYes
=
=0A>Doesn't it run in current process's context ?
=0AYou got it worng=
here. It runs on behalf of the process, but in the current process's conte=
xt.
=0AFor interrupts we have a dirrerent context altogether.
=0A>=
;
=0A>What am i missing here?
=0AThere are two different contexts =
of execution
=0AProcess context
=0AInterrupt context
=0A>
=
=0A>Thanks
=0A>~psr
=0A>
=0AThanks,
=0A-Rohit
=0A&g=
t;What
=0A>>is a context, then? It is the state information for a =
process. This
=0A>>includes the kernel and userspace stack pointer=
s, the register set,
=0A>>and the page tables for that process. Th=
e scheduler has access to all
=0A>>this information, to preempt on=
e process and run another. Contrary to
=0A>>this, an interrupt, de=
pending on the version of your kernel and arch,
=0A>>uses a separa=
te irq stack or the kernel stack of the interrupted
=0A>>process. =
An irq is not a context but merely a temporary execution to
=0A>>b=
e concluded asap.
=0A>>
=0A>>Hope this helps,
=0A>&=
gt;Bahadir
=0A>>
=0A>
=0A>
=0A>
=0A>-- pla=
y the game
=0A
=0A
=3D57 cellspacing=3D0 cellpadding=3D0 style=3D'font-family:Verdana;font-siz=
e:11px;line-height:15px;'>
bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/1050 715198@Middle5/=
1177315_1171298/1176420/1?PARTNER=3D3&OAS_QUERY=3Dnull target=3Dnew '>
src =3Dhttp://imadworks.rediff.com/cgi-bin/AdWorks/adimage.cgi/1 177315_1171=
298/creative_1176420.gif alt=3D'Peanuts' border=3D0> |
--Next_1179221663---0-202.54.124.237-1119--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Why can"t we sleep in an ISR?
am 15.05.2007 11:46:47 von pradeep singh
------=_Part_159383_12638171.1179222407269
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 15 May 2007 09:34:23 -0000, rohit hooda
wrote:
>
>
>
>
> On Tue, 15 May 2007 pradeep singh wrote :
> >On 5/14/07, Bahadir Balban wrote:
> >>
> >>On 5/14/07, Learning Linux wrote:
> >> > Ok, but how about an ISR, that does not take any locks? Why can't we
> >> > sleep in SUCH an ISR?
> >> > LL
> >> > -
> >>
> >>The killer reason why you can't sleep in an interrupt is because an
> >>interrupt is not associated with any context in the first place.
> >
> >
> >good enough, but i have a query regarding this then.
> >On a 8K kernel stack system, doesn't interrupts share the stack
> associated
> >with the current process which was interrupted?
> Yes, you are right.
> >Doesn't interrupt steals the CPU slice time allocated to the running
> process
> >to run?
> Yes
> >Doesn't it run in current process's context ?
> You got it worng here. It runs on behalf of the process, but in the
> current process's context.
> For interrupts we have a dirrerent context altogether.
>
Ok, that explains a bit.
how will you define an interrupt context?
Thanks
~psr
>
> >What am i missing here?
> There are two different contexts of execution
> Process context
> Interrupt context
> >
> >Thanks
> >~psr
> >
> Thanks,
> -Rohit
> >What
> >>is a context, then? It is the state information for a process. This
> >>includes the kernel and userspace stack pointers, the register set,
> >>and the page tables for that process. The scheduler has access to all
> >>this information, to preempt one process and run another. Contrary to
> >>this, an interrupt, depending on the version of your kernel and arch,
> >>uses a separate irq stack or the kernel stack of the interrupted
> >>process. An irq is not a context but merely a temporary execution to
> >>be concluded asap.
> >>
> >>Hope this helps,
> >>Bahadir
> >>
> >
> >
> >
> >-- play the game
>
>
> [image: Peanuts]
--
play the game
------=_Part_159383_12638171.1179222407269
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 15 May 2007 09:34:23 -0000, rohit hooda <> wrote:
On Tue, 15 May 2007 pradeep singh wrote :
>On 5/14/07, Bahadir Balban <
bahadir.balban@gmail.com> wrote:
>>
>>On 5/14/07, Learning Linux <learninglinux4@gmail.com
> wrote:
>> > Ok, but how about an ISR, that does not take any locks? Why can't we
>> > sleep in SUCH an ISR?
>> > LL
>> > -
>>
>>The killer reason why you can't sleep in an interrupt is because an
>>interrupt is not associated with any context in the first place.
>
>
>good enough, but i have a query regarding this then.
>On a 8K kernel stack system, doesn't interrupts share the stack associated
>with the current process which was interrupted?
Yes, you are right.
>Doesn't interrupt steals the CPU slice time allocated to the running process
>to run?
Yes
>Doesn't it run in current process's context ?
You got it worng here. It runs on behalf of the process, but in the current process's context.
For interrupts we have a dirrerent context altogether.
Ok, that explains a bit.
how will you define an interrupt context?
Thanks
~psr
>
>What am i missing here?
There are two different contexts of execution
Process context
Interrupt context
>
>Thanks
>~psr
>
Thanks,
-Rohit
>What
>>is a context, then? It is the state information for a process. This
>>includes the kernel and userspace stack pointers, the register set,
>>and the page tables for that process. The scheduler has access to all
>>this information, to preempt one process and run another. Contrary to
>>this, an interrupt, depending on the version of your kernel and arch,
>>uses a separate irq stack or the kernel stack of the interrupted
>>process. An irq is not a context but merely a temporary execution to
>>be concluded asap.
>>
>>Hope this helps,
>>Bahadir
>>
>
>
>
>-- play the game
--
play the game
------=_Part_159383_12638171.1179222407269--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Why can"t we sleep in an ISR?
am 15.05.2007 18:57:36 von Phillip Susi
Dong Feng wrote:
>> Doesn't it run in current process's context ?
>>
>
> No. I think the concept of process context is a higher-level logical
> concept. Though the interrupt share stack with the interrupted
> process, in my opinion it logically does not share the context with
> the process.
No, the term context here has a specific meaning. It refers to those
things which flow from the current pointer, including the virtual memory
space, file descriptor table, current uid, and so forth. Because the
current pointer is not changed on entry to an ISR, the ISR is executing
in the context of the interrupted process, and thus uses that process'
virtual memory, etc.
Re: Why can"t we sleep in an ISR?
am 16.05.2007 00:49:16 von Dong Feng
2007/5/16, Phillip Susi :
> Dong Feng wrote:
> >> Doesn't it run in current process's context ?
> >>
> >
> > No. I think the concept of process context is a higher-level logical
> > concept. Though the interrupt share stack with the interrupted
> > process, in my opinion it logically does not share the context with
> > the process.
>
> No, the term context here has a specific meaning. It refers to those
> things which flow from the current pointer, including the virtual memory
> space, file descriptor table, current uid, and so forth. Because the
> current pointer is not changed on entry to an ISR, the ISR is executing
> in the context of the interrupted process, and thus uses that process'
> virtual memory, etc.
>
If what you say were true, then an ISR would be running in the same
context as the interrupted process. But please check any article or
book, it will say ISR running in different context from any process.
So ISR is considered in its own context, although it shares a lot of
things with the interrupted process. I would only say *context* is a
higher-level logical concept.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 16.05.2007 17:20:53 von Phillip Susi
Dong Feng wrote:
> If what you say were true, then an ISR would be running in the same
> context as the interrupted process.
Yes, and it is, as others have said in this thread, which is a good
reason why ISRs can't sleep.
> But please check any article or
> book, it will say ISR running in different context from any process.
> So ISR is considered in its own context, although it shares a lot of
> things with the interrupted process. I would only say *context* is a
> higher-level logical concept.
Depends on which book or article you are reading I suppose. The
generally accepted and often used thought is that ISRs technically are
running in the context of the interrupted process, but because that
context is unknown and therefore should not be used, it is often said
that they run in no context, or outside of any context. Sometimes
people then assume that because they run outside of any ( particular )
process context, they must be in their own context, but this is a mistake.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 17.05.2007 01:17:36 von Dong Feng
OK. I think the gap between you and me is the definition of term
*context*. If you go to Linux Kernel Development, 2nd Edition (ISBN
0-672-32720-1), Page 6, then you will read the following:
..... in Linux, ... each processor is doing one of three things at any
given moment:
1. In kernel-space, in process context, ...
2. In kernel-space, in interrupt context, not associated with a process, ...
3. In user-space ...
This list is inclusive. ...
Maybe you prefer other terminology system, but I do like the above
definition given by Robert Love. So maybe in your system *context*
mean something at hardware level and you say ISR is in process
context, but I think it is more like a logical level and agree with
Rovert's definition.
And in hardware level, Robert's *context* definition also mean
something specific, that I started to be aware of. That is, *in the
same context* means a kernel-code is triggered by a user-space code.
*in different context* means a kernel-code is triggered by an external
interrupt source other than a user-space code.
Context has nothing to do with whether an ISR borrow any data
structure of a process, instead, its something logical or related to
causality.
2007/5/16, Phillip Susi :
> Dong Feng wrote:
> > If what you say were true, then an ISR would be running in the same
> > context as the interrupted process.
>
> Yes, and it is, as others have said in this thread, which is a good
> reason why ISRs can't sleep.
>
> > But please check any article or
> > book, it will say ISR running in different context from any process.
> > So ISR is considered in its own context, although it shares a lot of
> > things with the interrupted process. I would only say *context* is a
> > higher-level logical concept.
>
> Depends on which book or article you are reading I suppose. The
> generally accepted and often used thought is that ISRs technically are
> running in the context of the interrupted process, but because that
> context is unknown and therefore should not be used, it is often said
> that they run in no context, or outside of any context. Sometimes
> people then assume that because they run outside of any ( particular )
> process context, they must be in their own context, but this is a mistake.
>
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 17.05.2007 18:07:01 von Phillip Susi
Dong Feng wrote:
> OK. I think the gap between you and me is the definition of term
> *context*. If you go to Linux Kernel Development, 2nd Edition (ISBN
> 0-672-32720-1), Page 6, then you will read the following:
>
> .... in Linux, ... each processor is doing one of three things at any
> given moment:
>
> 1. In kernel-space, in process context, ...
> 2. In kernel-space, in interrupt context, not associated with a process,
> ...
> 3. In user-space ...
>
> This list is inclusive. ...
Yep, I disagree with that use of the term, because it is misleading and
caused your confusion. The context that the ISR executes in is not
associated with a _known_ process is more correct.
> Maybe you prefer other terminology system, but I do like the above
> definition given by Robert Love. So maybe in your system *context*
> mean something at hardware level and you say ISR is in process
> context, but I think it is more like a logical level and agree with
> Rovert's definition.
>
> And in hardware level, Robert's *context* definition also mean
> something specific, that I started to be aware of. That is, *in the
> same context* means a kernel-code is triggered by a user-space code.
> *in different context* means a kernel-code is triggered by an external
> interrupt source other than a user-space code.
Right, and that becomes more clear when you say that the ISR's is
executing in an indeterminate process context, rather than saying it
does not have any context at all, or has its own special context.
> Context has nothing to do with whether an ISR borrow any data
> structure of a process, instead, its something logical or related to
> causality.
No, it has everything to do with the data structures of the process.
When you are executing "in the same context" as you put it, as called
from the user mode code, you know you are using the task structure of
that process and so you can make use of that structure. For example,
you can look at the current uid to decide if you should allow an
operation to proceed. When you are in an ISR, there _is_ a task
structure there, but you shouldn't use it because you don't know which
task structure it is because you don't know which task you are
interrupting. Thus if you look at the current uid in an ISR, you have
no idea what you will see there and it will change from interrupt to
interrupt, depending on which task gets interrupted.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Why can"t we sleep in an ISR?
am 18.05.2007 01:50:50 von Dong Feng
Hi, Phillip,
I have said the gap between you and me is the definition of context.
In Robert's definition, *context* is used in a classification method
and really something in higher-level. And I used that term to explain
why ISR can not sleep.
If you do not like the name, name it your way and substitute term
*context* in my previous mail with what you name. But I believe my
other explaination still hold, right?
And again, if anyway I am forced to use your termnology system, I
would also agree your other point regarding hardware.
2007/5/18, Phillip Susi :
> Dong Feng wrote:
> > OK. I think the gap between you and me is the definition of term
> > *context*. If you go to Linux Kernel Development, 2nd Edition (ISBN
> > 0-672-32720-1), Page 6, then you will read the following:
> >
> > .... in Linux, ... each processor is doing one of three things at any
> > given moment:
> >
> > 1. In kernel-space, in process context, ...
> > 2. In kernel-space, in interrupt context, not associated with a process,
> > ...
> > 3. In user-space ...
> >
> > This list is inclusive. ...
>
> Yep, I disagree with that use of the term, because it is misleading and
> caused your confusion. The context that the ISR executes in is not
> associated with a _known_ process is more correct.
>
> > Maybe you prefer other terminology system, but I do like the above
> > definition given by Robert Love. So maybe in your system *context*
> > mean something at hardware level and you say ISR is in process
> > context, but I think it is more like a logical level and agree with
> > Rovert's definition.
> >
> > And in hardware level, Robert's *context* definition also mean
> > something specific, that I started to be aware of. That is, *in the
> > same context* means a kernel-code is triggered by a user-space code.
> > *in different context* means a kernel-code is triggered by an external
> > interrupt source other than a user-space code.
>
> Right, and that becomes more clear when you say that the ISR's is
> executing in an indeterminate process context, rather than saying it
> does not have any context at all, or has its own special context.
>
> > Context has nothing to do with whether an ISR borrow any data
> > structure of a process, instead, its something logical or related to
> > causality.
>
> No, it has everything to do with the data structures of the process.
> When you are executing "in the same context" as you put it, as called
> from the user mode code, you know you are using the task structure of
> that process and so you can make use of that structure. For example,
> you can look at the current uid to decide if you should allow an
> operation to proceed. When you are in an ISR, there _is_ a task
> structure there, but you shouldn't use it because you don't know which
> task structure it is because you don't know which task you are
> interrupting. Thus if you look at the current uid in an ISR, you have
> no idea what you will see there and it will change from interrupt to
> interrupt, depending on which task gets interrupted.
>
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: Re: Why can"t we sleep in an ISR?
am 18.05.2007 09:44:56 von pradeep singh
T24gNS8xOC8wNywg6ZmI5rabIDxlYXN0YWdlQGNvc2hpcC5jb20+IHdyb3Rl Ogo+IERlYXIgYWxs
Ogo+ICAgICAgICAgQXMgeW91IGJvdGggYWdyZWUgdG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hl
cmVvZi4gQW55IGRpc3NlbWluYXRpb24sIGRpc3RyaWJ1dGlvbiBvciBjb3B5 aW5nIG9mIHRoaXMg
Y29tbXVuaWNhdGlvbiBpcyBTVFJJQ1RMWSBQUk9ISUJJVEVELiBUaGFuayB5 b3UhCj4KPgo+Cj4K
CgotLSAKcGxheSB0aGUgZ2FtZQo=
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ