From owner-freebsd-questions@FreeBSD.ORG Thu Jul 7 10:37:02 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BFB961065675 for ; Thu, 7 Jul 2011 10:37:02 +0000 (UTC) (envelope-from steveayre@gmail.com) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by mx1.freebsd.org (Postfix) with ESMTP id 540D08FC0C for ; Thu, 7 Jul 2011 10:37:01 +0000 (UTC) Received: by fxe6 with SMTP id 6so821948fxe.17 for ; Thu, 07 Jul 2011 03:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=rdwkqaeTuGQbimsbWZ4zin5bprqkUFwlnhFUn99uYC4=; b=jylAInvd/5QE9DdT2HsiOTwRLJm6U3me8TUXlWCErN4refL3zWnQYSdUtQfWcarMXD qI8hD75j1Ttl/SEtRVXauKyXBTer972yFiMfjf32Hjnqxgz6ZM8DqWqi9hDQdjbgejwa XSl+0WYQiSgiUqTe/E9oCLIa9Yup7v6pZGB7A= Received: by 10.223.60.7 with SMTP id n7mr1005493fah.51.1310033241071; Thu, 07 Jul 2011 03:07:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.126.195 with HTTP; Thu, 7 Jul 2011 03:06:51 -0700 (PDT) From: Steven Ayre Date: Thu, 7 Jul 2011 11:06:51 +0100 Message-ID: To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: kqueue + EVFILT_TIMER unreliable timing problems X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 10:37:02 -0000 Hi everyone, I'm trying to use kqueue with EVFILT_TIMER to create an interval timer. However, I'm getting very unreliable results. The code for a test case is at: http://pastebin.com/ratK0AXL I'm finding that regardless of the number of ticks I wait for, it takes around 50% longer than it should. For a 20ms interval, 200 ticks takes 6s not 4s, 2000 takes 60s not 40s. I am running FreeBSD within a virtualbox VM (Windows host, no load) so I know timing may not be as reliable as if I was on the bare metal, but this still much higher than expected. -Steve