From owner-svn-src-all@FreeBSD.ORG Wed Oct 17 08:14:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3291CC67; Wed, 17 Oct 2012 08:14:59 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [64.62.153.212]) by mx1.freebsd.org (Postfix) with ESMTP id 11BE88FC08; Wed, 17 Oct 2012 08:14:59 +0000 (UTC) Received: from Xins-MacBook-Pro.local (c-67-188-85-47.hsd1.ca.comcast.net [67.188.85.47]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by anubis.delphij.net (Postfix) with ESMTPSA id 760051D65D; Wed, 17 Oct 2012 01:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=delphij.net; s=anubis; t=1350461698; bh=hkkfELo1Bi4m5E5o60ArRD/xZAN9ysDOeP01a+4jAzA=; h=Date:From:Reply-To:To:CC:Subject:References:In-Reply-To; b=lBIHWQj+spm9B/5arze5UNow5bVInaVddBJILGTjHpSEvkiBXZE21yqnlo+2I9Br+ 31UDBqaWPKmDmE7S8GJuUHcuT0JZCYGVVRvXD0nD6n/nQOt0MTe2oVsg1ifcdOhU1Z WZMey2srq8DARD1Twl5x+pTHu8wUjIfBLcOsDCWs= Message-ID: <507E6901.8040801@delphij.net> Date: Wed, 17 Oct 2012 01:14:57 -0700 From: Xin Li Organization: The FreeBSD Project MIME-Version: 1.0 To: Maxim Sobolev Subject: Re: svn commit: r241625 - head/usr.sbin/cron/cron References: <201210170044.q9H0iZHo055977@svn.freebsd.org> In-Reply-To: <201210170044.q9H0iZHo055977@svn.freebsd.org> X-Enigmail-Version: 1.4.5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: d@delphij.net List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2012 08:14:59 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, On 10/16/12 5:44 PM, Maxim Sobolev wrote: > Author: sobomax Date: Wed Oct 17 00:44:34 2012 New Revision: > 241625 URL: http://svn.freebsd.org/changeset/base/241625 > > Log: o Use nanosleep(2) to sleep exact amount of time till the next > second, not multiple of 1 second, which results in actual time to > drift back and forth every run within 1 second of the actual action > has been set for. > > Suggested by: Ian Lepore > > o Schedule the first run in 1 second after starting up, not on the > boundary of the next minute, which results in the every_second > jobs not being run. > > for (;;) { - seconds_to_wait = (int) (TargetTime - > time((time_t*)0)); + gettimeofday(&ctime, NULL); Could you please replace this with clock_gettime(CLOCK_REALTIME_FAST)? This also gives us time in timespec, suitable for use with nanosleep, plus save some code for the subtract helper. -----BEGIN PGP SIGNATURE----- iQEcBAEBCAAGBQJQfmkBAAoJEG80Jeu8UPuz1QgH/2YALytmL6l6cTwzku7MqMjV 7JlYyje1GCJ5fnUUxyEl19ZSeHExGXCi8UWLHAvR3Y8uDqZ+NBY3iDRckKexbbfZ fWJhmrDUeon1i9BG4nYSWZQ/M2XvEAfr31hNgH7aEHVI81KBxaStBNi11HEQsR70 gdSBAdkB/SVgD76FgTuwPChcusJhf5egv28K6yWPUyzR2x3berS2h3eAmj1I1CDo buDi9HUQCSSrFSHNeKawPq9iOGkuDs/yvAUd1e+OWXPtD+RWBhuqIi0U141w6yRy hEE3wWUTjChg9e4r9oCsUx5tKPeNXbV136txj8LVZKahfOxyRF/Ac4H7C/6pFpI= =HdF2 -----END PGP SIGNATURE-----