• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: kqueue timer interval fence post error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kqueue timer interval fence post error?


  • Subject: Re: kqueue timer interval fence post error?
  • From: Shantonu Sen <email@hidden>
  • Date: Wed, 18 Jul 2012 10:40:44 -0700

<http://www.opensource.apple.com/source/xnu/xnu-1699.26.8/>

Timers can skew for a variety of reasons, including system load, and power management. Considering that 20ms isn't that much more than a scheduling quantum, actual delivery of notifications can vary widely, especially on UP systems.

Shantonu

On Jul 18, 2012, at 7:21 AM, Paul Albrecht <email@hidden> wrote:

> Hi,
>
> Doesn't seem like the kqueue timer works correctly on os x. When I use
> the timer on my mac it consistently runs slow. Here's some test code:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
> #include <errno.h>
> #include <sys/types.h>
> #include <sys/event.h>
> #include <sys/time.h>
>
> int
> main(void)
> {
>        int i,msec;
>        int kq,nev;
>        struct kevent inqueue;
>        struct kevent outqueue;
>        struct timeval start,end;
>
>        if ((kq = kqueue()) == -1) {
>                fprintf(stderr, "kqueue error!? errno = %s", strerror(errno));
>                exit(EXIT_FAILURE);
>        }
>        EV_SET(&inqueue, 1, EVFILT_TIMER, EV_ADD | EV_ENABLE, 0, 20, 0);
>
>        gettimeofday(&start, 0);
>        for (i = 0; i < 50; i++) {
>                if ((nev = kevent(kq, &inqueue, 1, &outqueue, 1, NULL)) == -1) {
>                        fprintf(stderr, "kevent error!? errno = %s", strerror(errno));
>                        exit(EXIT_FAILURE);
>                } else if (outqueue.flags & EV_ERROR) {
>                        fprintf(stderr, "EV_ERROR: %s\n", strerror(outqueue.data));
>                        exit(EXIT_FAILURE);
>                }
>        }
>        gettimeofday(&end, 0);
>
>        msec = ((end.tv_sec - start.tv_sec) * 1000) + (((1000000 + end.tv_usec - start.tv_usec) / 1000) - 1000);
>
>        printf("msec = %d\n", msec);
>
>        close(kq);
>        return EXIT_SUCCESS;
> }
>
> I originally noticed the problem on freebsd. After I posted to the
> freebsd-hackers mailing list I got a fix, but that doesn't do much good
> on my mac since I don't have the source.
>
> --
> Paul Albrecht
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: kqueue timer interval fence post error?
      • From: Paul Albrecht <email@hidden>
References: 
 >kqueue timer interval fence post error? (From: Paul Albrecht <email@hidden>)

  • Prev by Date: kqueue timer interval fence post error?
  • Next by Date: Active Directory bind, opendirectoryd, and indentitysvc()
  • Previous by thread: kqueue timer interval fence post error?
  • Next by thread: Re: kqueue timer interval fence post error?
  • Index(es):
    • Date
    • Thread