Subject: Re: [patch/rfc] eventfd semaphore-like behavior

On Thu, Feb 5, 2009 at 2:02 AM, Davide Libenzi <[email protected]> wrote:
> On Thu, 5 Feb 2009, Michael Kerrisk wrote:
>
>> > Dunno. ?Probably try the syscall and see if it returned -EINVAL. ?Does
>> > that work in this case?
>>
>> As youll have seen by now, Ulrich and I noted that it works.
>>
>> > If so, it would be sensible to mention this in
>> > the description somewhere as the approved probing method and to
>> > maintain it.
>>
>> I'll add something to the man page, as this patch progresses.
>
> I see we already have stuff like this inside the man pages:
>
> O_CLOEXEC (Since Linux 2.6.23)
> ? ? ? ? ?Enable the close-on-exec flag for the new file descriptor.
> ? ? ? ? ?...
>
> Maybe a similar note for the new flag?

It took a while, but here's the new text in the eventfd.2 (will be in
man-pages-2.36). Could you please ACK, Davide?

EFD_SEMAPHORE (since Linux 2.6.30)
Provide semaphore-like semantics for reads from
the new file descriptor. See below.
...
* If EFD_SEMAPHORE was not specified and the
eventfd counter has a nonzero value, then a
read(2) returns 8 bytes containing that value,
and the counter's value is reset to zero.

* If EFD_SEMAPHORE was specified and the eventfd
counter has a nonzero value, then a read(2)
returns 8 bytes containing the value 1, and the
counter's value is decremented by 1.

Thanks,

Michael

--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/


Subject: Re: [patch/rfc] eventfd semaphore-like behavior

On Mon, Aug 30, 2010 at 7:21 AM, Michael Kerrisk <[email protected]> wrote:

> It took a while, but here's the new text in the eventfd.2 (will be in
> man-pages-2.36). Could you please ACK, Davide?

Oops: s/2.36/3.26/

--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/

2010-08-30 14:23:07

by Davide Libenzi

[permalink] [raw]
Subject: Re: [patch/rfc] eventfd semaphore-like behavior

On Mon, 30 Aug 2010, Michael Kerrisk wrote:

> On Thu, Feb 5, 2009 at 2:02 AM, Davide Libenzi <[email protected]> wrote:
> > On Thu, 5 Feb 2009, Michael Kerrisk wrote:
> >
> >> > Dunno. ?Probably try the syscall and see if it returned -EINVAL. ?Does
> >> > that work in this case?
> >>
> >> As youll have seen by now, Ulrich and I noted that it works.
> >>
> >> > If so, it would be sensible to mention this in
> >> > the description somewhere as the approved probing method and to
> >> > maintain it.
> >>
> >> I'll add something to the man page, as this patch progresses.
> >
> > I see we already have stuff like this inside the man pages:
> >
> > O_CLOEXEC (Since Linux 2.6.23)
> > ? ? ? ? ?Enable the close-on-exec flag for the new file descriptor.
> > ? ? ? ? ?...
> >
> > Maybe a similar note for the new flag?
>
> It took a while, but here's the new text in the eventfd.2 (will be in
> man-pages-2.36). Could you please ACK, Davide?
>
> EFD_SEMAPHORE (since Linux 2.6.30)
> Provide semaphore-like semantics for reads from
> the new file descriptor. See below.
> ...
> * If EFD_SEMAPHORE was not specified and the
> eventfd counter has a nonzero value, then a
> read(2) returns 8 bytes containing that value,
> and the counter's value is reset to zero.
>
> * If EFD_SEMAPHORE was specified and the eventfd
> counter has a nonzero value, then a read(2)
> returns 8 bytes containing the value 1, and the
> counter's value is decremented by 1.

Looks fine to me.


- Davide