Skip to contentSkip to conversation

Why can't we sleep in an ISR?

DISCUSSION rohit hooda 2 participants 2 messages May 15, 2007

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · On Tue, 15 May 2007 pradeep singh wrote :
Quoted 7 lines · Bahadir Balban
Quoted 4 lines · Learning Linux

Ok, but how about an ISR, that does not take any locks? Why can't we sleep in SUCH an ISR?
LL
-

Quoted 7 lines
Quoted 2 lines

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.

Quoted 2 lines

Doesn't interrupt steals the CPU slice time allocated to the running process to run?

Yes

Quoted 1 line

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.

Quoted 2 lines

What am i missing here?

There are two different contexts of execution
Process context
Interrupt context

Quoted 4 lines

Thanks
~psr

Thanks,
-Rohit

Quoted 17 lines

What

Quoted 9 lines

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.

Quoted 3 lines

Hope this helps,
Bahadir

-- play the game

#1 lore raw
Quoted 22 lines · rohit hooda
Quoted 8 lines · On Tue, 15 May 2007 pradeep singh wrote :
Quoted 7 lines · Bahadir Balban
Quoted 4 lines · Learning Linux

Ok, but how about an ISR, that does not take any locks? Why can't we sleep in SUCH an ISR?
LL
-

Quoted 6 lines
Quoted 2 lines

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

Quoted 1 line

with the current process which was interrupted?

Yes, you are right.

Quoted 9 lines
Quoted 1 line

Doesn't interrupt steals the CPU slice time allocated to the running

process

Quoted 1 line

to run?

Yes

Quoted 1 line

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

Quoted 31 lines
Quoted 2 lines

What am i missing here?

There are two different contexts of execution
Process context
Interrupt context

Quoted 4 lines

Thanks
~psr

Thanks,
-Rohit

Quoted 10 lines

What

Quoted 9 lines

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.

Quoted 7 lines
Quoted 3 lines

Hope this helps,
Bahadir

-- play the game

[image: Peanuts]<http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/1050715198@Middle5/1177315_1171298/1176420/1?PARTNER=3&OAS_QUERY=null+target=new+>

Signature · 1 line
play the game