Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 15 Oct 2002 18:13:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 15 Oct 2002 18:13:40 -0400 Received: from x35.xmailserver.org ([208.129.208.51]:12692 "EHLO x35.xmailserver.org") by vger.kernel.org with ESMTP id ; Tue, 15 Oct 2002 18:13:11 -0400 X-AuthUser: davidel@xmailserver.org Date: Tue, 15 Oct 2002 15:27:10 -0700 (PDT) From: Davide Libenzi X-X-Sender: davide@blue1.dev.mcafeelabs.com To: John Gardiner Myers cc: Benjamin LaHaise , Dan Kegel , Shailabh Nagar , linux-kernel , linux-aio , Andrew Morton , David Miller , Linus Torvalds , Stephen Tweedie Subject: Re: [PATCH] async poll for 2.5 In-Reply-To: <3DAC9035.2010208@netscape.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1409 Lines: 41 On Tue, 15 Oct 2002, John Gardiner Myers wrote: > Davide Libenzi wrote: > > >Why would you need to use threads with a multiplex-like interface like > >/dev/epoll ? > > > Because in some applications processing an event can cause the thread to > block, potentially for a long time. Multiple threads are needed to > isolate that block to the context associated with the event. I don't want this to become the latest pro/against threads but if your processing thread block for a long time you should consider handling the blocking condition asynchronously. If your procesing thread blocks, your application model should very likely be redesigned, or you just go with threads ( and you do not need any multiplex interface ). > > while (read() == EGAIN) > > wait(POLLIN); > > > > > Assuming registration of interest is inside wait(), this has a race. If > the file becomes readable between the time that read() returns and the > time that wait() can register interest, the connection will hang. Your assumption is wrong, the registration is done as soon as the fd "born" ( socket() or accept() for example ) and is typically removed when it dies. - Davide - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/