Re: Sleeping in the interrupt handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2003-07-01 at 09:22, Martin Maletinsky wrote:

> I know, that you are not allowed to sleep in an interrupt handler.
> How ever I am interested to understand the reason(s) for that. Was
> this a design decision (e.g. to simplify things) for the Linux
> kernel, or is there a fundamental reason that makes sleeping
> interrupt handlers simply impossible? What about the page fault
> handler - it (probably) sleeps when it has to swap in a page,
> why is it possible to sleep for the page fault handler and not for
> an interrupt handler?

You cannot sleep in an interrupt handler because interrupts do not have
a backing process context, and thus there is nothing to reschedule back
into. In other words, interrupt handlers are not associated with a task,
so there is nothing to "put to sleep" and (more importantly) "nothing to
wake up". They must run atomically.

This is not unlike other operating systems. In most operating systems,
interrupts are not threaded. Bottom halves often are, however.

The reason the page fault handler can sleep is that it is invoked only
by code that is running in process context. Because the kernel's own
memory is not pagable, only user-space memory accesses can result in a
page fault. Thus, only a few certain places (such as calls to
copy_{to,from}_user()) can cause a page fault within the kernel. Those
places must all be made by code that can sleep (i.e., process context,
no locks, et cetera).

Hope this helped.

	Robert Love


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux