Google Interview Question
Software Engineer / DevelopersI assume you mean pass from the network interface to the OS, for example, an Ethernet card. Typically the network interface driver allocates and pins memory. Tells the hardware to write into it. Then, with that block of host memory, passes off a pointer, list of pointers, or list of lists of pointers to the OS that indicates packets, fragment, pages (scatter/gathers). That way the CPU never copies the memory so it doesn't need to block on a slow bus or pull into it's cache after it has been DMA'ed.
This pointer structure is routed and usually winds up directly in a queue, or depending on where it was routed is serialized into a queue.
The question here is "What data structure would you use to pass 1MB of data to OS from network layer for packet delivering?". The wording "from network layer for packet delivering" is causing confusion.
To pass 1MB of data to OS for packet delivery, it is good to use "struct iovec" along with writev() syscall.
it should be queue ( assuming proper packet reordering is at OS level... )
- Anonymous September 19, 2010