[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090827143027.GA22720@redhat.com>
Date: Thu, 27 Aug 2009 17:30:27 +0300
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Davide Libenzi <davidel@...ilserver.org>
Cc: Paolo Bonzini <pbonzini@...hat.com>, Avi Kivity <avi@...hat.com>,
gleb@...hat.com, kvm@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 0/2] eventfd: new EFD_STATE flag
On Thu, Aug 27, 2009 at 07:21:49AM -0700, Davide Libenzi wrote:
> On Thu, 27 Aug 2009, Paolo Bonzini wrote:
>
> > > Ok, so why not using the eventfd counter as state?
> > > On the device side:
> > >
> > > void write_state(int sfd, int state) {
> > > u64 cnt;
> > >
> > > /* Clear the current state, sfd is in non-blocking mode */
> > > read(sfd,&cnt, sizeof(cnt));
> > > /* Writes new state */
> > > cnt = 1 + !!state;
> > > write(sfd,&cnt, sizeof(cnt));
> > > }
> >
> > It's interesting [no sarcasm intended, mind] that EFD_SEMAPHORE was
> > added exactly to avoid a read+write combination for the case of
> > decrementing a value.
>
> Like I repeated 25 times already, EFD_SEMAPHORE was added, because a
> *semaphore* is a pretty widely known and used abstraction.
what about an atomic variable, btw? does it make sense to implement
write that does compare and exchange?
>
> - Davide
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists