From: Gianni Tedesco
Date: Thu Nov 06 2003 - 09:32:33 EST

On Thu, 2003-11-06 at 15:13, Oliver Dain wrote:
> It seems to me that it can't loop in user mode forever. There is no way to
> get data into user mode (the ring buffer) witout going through the kernel.
> My understanding is that the NIC doesn't transfer directly to the user mode
> ring buffer, but rather to a different DMA buffer. The kernel must copy it
> from the DMA buffer to the ring buffer. Thus once the user mode app has
> processed all the data in the ring buffer the kenel _must_ get involved to
> get more data to user space. Currently the data gets there because the NIC
> produces an interrupt for each packet (or for every few packets) and when the
> kernel handles these the data is copied to user space. Then, as you point
> out, the cost of the RETI can't be avoided.

yes, in interrupt context. My point is that that *task* will never go in
to kernel mode, it will always be running in user mode.

> However, if the NIC could transfer the data directly to user space it wouldn't
> need to cause an interrupt and the cost of the RETI and the context switch is
> avoided. The user mode app really could process forever without sleeping at
> that point.

it would need to cause an interrupt to notify of the packet, unless the
program communicated directly with the NIC in polling mode. This the
point of mmap packet socket, provides a *portable* ring buffer structure
so that userspace doesn't have to reimplement drtivers.

// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D

Attachment: signature.asc
Description: This is a digitally signed message part