From owner-freebsd-hackers@FreeBSD.ORG Fri May 29 13:44:21 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DF734577; Fri, 29 May 2015 13:44:21 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from mail.embedded-brains.de (host-82-135-62-35.customer.m-online.net [82.135.62.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8BD52132B; Fri, 29 May 2015 13:44:21 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 97E002A1820; Fri, 29 May 2015 15:45:00 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 9t8i6-bUCWNm; Fri, 29 May 2015 15:44:59 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id A36CB2A192A; Fri, 29 May 2015 15:44:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id PQzzy_ECg6S0; Fri, 29 May 2015 15:44:59 +0200 (CEST) Received: from [192.168.96.129] (unknown [192.168.96.129]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 3E2D22A1820; Fri, 29 May 2015 15:44:59 +0200 (CEST) Message-ID: <55686D31.1060408@embedded-brains.de> Date: Fri, 29 May 2015 15:44:17 +0200 From: Sebastian Huber User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Poul-Henning Kamp CC: freebsd-hackers@freebsd.org Subject: Re: Problem with timecounters and memory model References: <55686300.3080100@embedded-brains.de> <85086.1432906578@critter.freebsd.dk> <55686C0F.9000101@embedded-brains.de> <85121.1432906871@critter.freebsd.dk> In-Reply-To: <85121.1432906871@critter.freebsd.dk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2015 13:44:22 -0000 On 29/05/15 15:41, Poul-Henning Kamp wrote: > -------- > In message <55686C0F.9000101@embedded-brains.de>, Sebastian Huber write= s: > >> Ok, what makes me wonder is why this problem didn't show up in FreeBSD= .=3D20 >> In our case we observed backward jumps in the supposed to be monotonic= =3D20 >> uptime. > How often do you "wind" the timecounter ? > More often than necessary. About 1000 times a second with only one=20 timehand (this is a hack to support legacy systems). The test case is: while (1) { struct timespec newtime; if (clock_gettime(CLOCK_MONOTONIC, &newtime) !=3D 0) { fprintf(stderr, "clock_gettime() failed: \"%s\"\n",=20 strerror(errno)); return (NULL); } if (!(newtime.tv_sec > lasttime.tv_sec || (newtime.tv_sec =3D=3D lasttime.tv_sec && newtime.tv_nsec >=3D lasttime.tv_nsec))) { printf("Time went backwards, from {%ld, %ld} to {%ld,=20 %ld}\n", lasttime.tv_sec, lasttime.tv_nsec, newtime.tv_sec,=20 newtime.tv_nsec); } lasttime =3D newtime; } --=20 Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.huber@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine gesch=E4ftliche Mitteilung im Sinne des EHUG.