Re: bottom half handler

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

 



On Thu, Aug 01, 2002 at 03:25:12PM -0000, Pichai  Raghavan wrote:
> According to my Linux book; bottom half handling has all the 
> interrupt restrictions of not doing sleep; schedule or accessing 
> user space. What is the reason?

The reason is, that bottom-halves are run in various ocasions when
scheduling, context switiching et. al. and no current is defined there.

To wait for something, you need a task_struct (current), that will be
put to a wait_queue and scheduled when awoken. You don't have that in
bottom-half as you run in context of whatever process happens to be
active at the moment.

If you need to wait for something in bottom half (or tasklet), you just
arrange it that another function is run when the resource is available.

> Again if the entire IP packet 
> processing happens in bottom half, does it mean that the IP stack 
> does not wait on any resources ?(this is hard to digest!)

Sure it does not wait for resources. What resources should it wait for?

There is an interrupt when NIC recieves a packet. The HW driver starts
DMA transfer in this interrupt and returns. When the transfer is
complete, another interrupt happens and the HW driver registers the
bottom half and returns. In next schedule, the bottom half is run and it
passes the packet. Everything is in memory at that point and all the
ethernet, ip and tcp/udp code has to do is figure out what queue to add
the packet in - which does not require copying. So no waiting there.

Copyig to userspace is done in the syscall on behalf of calling process
- there one can wait.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
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