Newsgroup: comp.os.linux.development.apps


Date: Tue, 11 Apr 2006 17:44:14 +0300
From: Diomidis Spinellis <dds@aueb.gr>
Organization: Athens University of Economics and Business
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0
MIME-Version: 1.0
Newsgroups: comp.os.linux.development.apps
Subject: Re: Busy wait vs something better
References: <4436a85a$0$487$626a54ce@news.free.fr>
In-Reply-To: <4436a85a$0$487$626a54ce@news.free.fr>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Grumble wrote:
> [ Followup-To set to comp.os.linux.development.apps ]
> 
> Hello,
> 
> I'm working on a Linux application that is supposed to process UDP
> packets at a high rate: roughly 4 packets per ms.
> 
> Right now, the receiver busy waits on the socket to minimize the delay
> between the time when the packet reaches the network card and the time
> when the application gets to process the packet.
> 
> The actual processing accounts only for 1-2% of the CPU utilization,
> 98-99% is wasted in the busy wait loop.
> 
> I've been told that the usual "better" approaches, like using select()
> to sleep while waiting for new packets, do not work, because (??) the
> arrival rate is larger than the time quantum (1 ms on recent kernels?).
> 
> I'm very open to suggestions, opinions, ideas...
> 
> I'll also take links to papers / articles discussing implementation of
> similar systems.
> 
> (I'm working with kernel 2.6.14.6 in case it matters.)

What you've been told is wrong, because the time quantum is related to 
involuntary context switches and multiple processes competing for the 
processor's attention.  When you voluntarily give up control by calling 
select(2) on a relatively idle system, the kernel can immediately return 
to your applicaiton if data is available.  And, anyway, 1ms is an 
eternity for modern processors: obtaining four packets in that time 
interval is not a big deal.

Diomidis - http://www.spinellis.gr



Newsgroup comp.os.linux.development.apps contents
Newsgroup list
Diomidis Spinellis home page

Creative Commons License Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.