lkml.org 
[lkml]   [2009]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 0/2] eventfd: new EFD_STATE flag
On 08/26/2009 10:13 PM, Davide Libenzi 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));
> }
>
>
> On the hypervisor side:
>
> int read_state(int sfd) {
> u64 cnt;
>
> read(sfd,&cnt, sizeof(cnt));
> return state - 1;
> }
>
>

Hadn't though of read+write as set. While the 1+ is a little ugly, it's
workable.

I see no kernel equivalent to read(), but that's easily done.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.



\
 
 \ /
  Last update: 2009-08-26 21:45    [W:0.117 / U:1.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site