From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 0/2] eventfd: new EFD_STATE flag Date: Tue, 25 Aug 2009 08:59:33 +0200 Message-ID: <4A938BD5.1050302@gnu.org> References: <20090820155655.GA8764@redhat.com> <4A8D8A28.2050004@redhat.com> <20090820175540.GA9232@redhat.com> <4A8D90BB.2030506@redhat.com> <20090820182847.GB9282@redhat.com> <4A913DA9.1020403@redhat.com> <20090823133620.GA12841@redhat.com> <4A9146E3.2090007@redhat.com> <20090823143021.GA27495@redhat.com> <4A92DC93.6030406@redhat.com> <4A930FE4.6090209@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Avi Kivity , "Michael S. Tsirkin" , gleb@redhat.com, kvm@vger.kernel.org, Linux Kernel Mailing List To: Davide Libenzi Return-path: Received: from mail-bw0-f219.google.com ([209.85.218.219]:40972 "EHLO mail-bw0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754223AbZHYG7g (ORCPT ); Tue, 25 Aug 2009 02:59:36 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: >>> There are userspace libraries that do almost everything, but you hardly >>> see things like pthread_(EFD_STATE-like)_create() or similar system >>> interfaces based on such abstraction. >> >> It actually seems as close to a condition variable as an eventfd can be. > > A pthread condition typical code usage maps to eventfd like: > > while (read(efd, ...)> 0) > if (CONDITION) > break; > > So a pthread condition is really a wakeup gate like eventfd is. > EFD_STATE has nothing to do with a pthread condition. No, your code does not work for pthread_cond_broadcast (which arguably is the common case) because all the eventfd readers after the first would block. Paolo