Date: Wed, 17 Oct 2012 01:14:57 -0700 From: Xin Li <delphij@delphij.net> To: Maxim Sobolev <sobomax@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r241625 - head/usr.sbin/cron/cron Message-ID: <507E6901.8040801@delphij.net> In-Reply-To: <201210170044.q9H0iZHo055977@svn.freebsd.org> References: <201210170044.q9H0iZHo055977@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
-----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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?507E6901.8040801>