Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Oct 2022 00:55:30 +0300
From:      =?UTF-8?B?0K/RgNC+0YHQu9Cw0LIg0JzQsNGI0LrQvg==?= <yaroslaw.mashko@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   clarification on kqueue kernel event flags.
Message-ID:  <CAMVwyx%2BpagV6%2Bcp%2BMJCOz=HYvxDCCEVQBVkVYpi-%2BY9X80XOPg@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hello,

I got confused with EV_CLEAR flag. Some code follows.

  kev.ident  = 1;
  kev.filter = EVFILT_TIMER;
  kev.flags  = EV_ADD | EV_DISPATCH;
  kev.data   = 4;
  kev.fflags = NOTE_SECONDS;

 l_reg_ev:
  status = kevent(kq, &kev, 1, NULL, 0, NULL);

  for(;;){
   status = kevent(kq, NULL, 0, &kev, 1, NULL);
   kev.flags = EV_ENABLE;
   goto l_reg_ev;
  }

This prints the series of:

id      :  1
> flags   :  EV_DISPATCH EV_CLEAR
> filter  :  EVFILT_TIMER
> data    :  # times timeout has expired since last kevent call: 1
>

The "man kevent", the EV_CLEAR section says that:

> After the event is retrieved by the user, its state is reset.
>

What I expect is that after the first goto, the EV_DISPATCH flag gets
cleared. What does "the state" mean in the above?
More specifically, what exactly EV_CLEAR changes with any combination of
flags and filters?

P.S.
I did read a source code for "/sys/kern/kern_event.c". My brain fails to
understand it as a whole, so, please be easy on me.

-- 
Ярослав Машко

+380 50 56 75 347 <+380+50+56+75+347>

[-- Attachment #2 --]
<div dir="ltr"><div>Hello,</div><div><br></div><div>I got confused with EV_CLEAR flag. Some code follows.</div><div><br></div><div>  kev.ident  = 1;<br>  kev.filter = EVFILT_TIMER;<br>  kev.flags  = EV_ADD | EV_DISPATCH;<br>  kev.data   = 4;<br>  kev.fflags = NOTE_SECONDS;</div><div><br></div><div> l_reg_ev:</div><div>  status = kevent(kq, &amp;kev, 1, NULL, 0, NULL);</div><div><br></div><div>  for(;;){</div><div>   status = kevent(kq, NULL, 0, &amp;kev, 1, NULL);</div><div>   kev.flags = EV_ENABLE;</div><div>   goto l_reg_ev;</div><div>  }</div><div><br></div><div>This prints the series of:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>	id      :  1<br>	flags   :  EV_DISPATCH EV_CLEAR <br>	filter  :  EVFILT_TIMER<br>	data    :  # times timeout has expired since last kevent call: 1<br></div></blockquote><div> </div><div>The &quot;man kevent&quot;, the EV_CLEAR section says that: <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>After the event is retrieved by the user, its state is reset.</div></blockquote><div><br></div><div>What I expect is that after the first goto, the EV_DISPATCH flag gets cleared. What does &quot;the state&quot; mean in the above?</div><div>More specifically, what exactly EV_CLEAR changes with any combination of flags and filters?</div><div><br></div><div>P.S.<br></div><div>I did read a source code for &quot;/sys/kern/kern_event.c&quot;. My brain fails to understand it as a whole, so, please be easy on me.<br></div><div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Ярослав Машко</div><div dir="ltr"><br><div><a href="tel:+380+50+56+75+347" target="_blank">+380 50 56 75 347</a></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMVwyx%2BpagV6%2Bcp%2BMJCOz=HYvxDCCEVQBVkVYpi-%2BY9X80XOPg>