From owner-freebsd-hackers@freebsd.org Thu Dec 15 00:29:39 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7166DC80D24 for ; Thu, 15 Dec 2016 00:29:39 +0000 (UTC) (envelope-from meka@tilda.center) Received: from mail.tilda.center (mail.tilda.center [188.226.130.133]) by mx1.freebsd.org (Postfix) with ESMTP id 2F8EB1DD3; Thu, 15 Dec 2016 00:29:38 +0000 (UTC) (envelope-from meka@tilda.center) Received: from hal9000.meka.no-ip.org (unknown [87.116.181.51]) by mail.tilda.center (Postfix) with ESMTPSA id 2A98E61551; Thu, 15 Dec 2016 01:29:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=tilda.center; s=mail; t=1481761746; bh=3doPPtODrFPljFBh9Hpz5gr9Kx+0WEE65ciMFSf+klc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U8d+calvSTVQ4QmhR2xX+S3u7pIrVhJJ8+rscEC4WOR5/aTVnnZCrGMFQ4/ndSDGR +68mFpmnVyOPXckZ8OV2bS+EogJsDr0xT6xml6IRZo5kt5frS9WJNyvKIOsMJnOQr2 iaJVQv5M1Qc9I1bi6DDxrcYGV1vCR6wRLt5njTTk= Date: Thu, 15 Dec 2016 01:29:06 +0100 From: Goran =?utf-8?B?TWVracSH?= To: Ian Lepore Cc: freebsd-hackers@freebsd.org Subject: Re: How to use sem_timedwait? Message-ID: <20161215002906.mllorgvvuovbdtze@hal9000.meka.no-ip.org> References: <20161214074228.zh6q5zya2gszw4g6@hal9000.meka.no-ip.org> <1481748960.1889.398.camel@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hrhuntinyslroab3" Content-Disposition: inline In-Reply-To: <1481748960.1889.398.camel@freebsd.org> User-Agent: NeoMutt/20161126 (1.7.1) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2016 00:29:39 -0000 --hrhuntinyslroab3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 14, 2016 at 01:56:00PM -0700, Ian Lepore wrote: > On Wed, 2016-12-14 at 08:42 +0100, Goran Meki=C4=87 wrote: > One of the things you did with that code is measured how much time it > took to format and print the "It should have ended..." line. =C2=A0If you > want to capture how long you were asleep you need the clock_gettime() > to be the next thing you call after sem_timedwait(). =C2=A0Even the time = to > access errno may be non-trivial if it's actually a thread-local > variable. > > If you want to get better sleep-timing performance (at the expense of > less power-saving efficiency), try setting > > =C2=A0 sysctl kern.timecounter.alloweddeviation=3D0 > > That will prevent the aggregation of timeouts scheduled near each other > to all happen at the same time, resulting in more wakeups, each of > which is more accurate (more wakeups =3D more power used). > > -- Ian > This is exactly what I've needed. Thank you so much. If you can tell me any= other tip to make the difference even smaller, I'd be grateful. Currently,= it goes from 0.1ms to 1ms. Great improvement! Once more, thank you very mu= ch! Regards, meka --hrhuntinyslroab3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE1WIFkXy2ZeMKjjKEWj1TknovrLYFAlhR488ACgkQWj1Tknov rLbjixAAnqaNtBOX9tv04Udv5UX6gN947P2fSOnTz0/VBKl2Mlu24uRtJ3AL/Bhl VWn2mJiS4zR/ty/S4bajCso+rJwjTEeo9PJ7TGA9j0RmSXWht4K+V2lJH0dZKWCD FOKAJWkZVQugcv+ESzw3AXmzGe8mXoyivcPAa9Wr+Irt8U7U+9OckhrOTTghJ9EL n+PrtYf9DKpsugjaJ5NWKrTdASIYOyjIxXuUaW5hdHV5f5+Q5ZOx4PK8XJkM5YvK 2d9/HZfFRyFby+8+Exy6/9cTkaxaQgTNjcKhXgCOq7rn1gYxfbKol8WyG9LQmF24 cibW+frmX9Xi2uvB4E9Sr8qs3TPz2hhfD0Qgfnhlbmk3th9q7gmk++kf+tPDoJwG QzjA0qaJufrFEwVz7/faZb2S8wuGr8U/TMTwXPlMOAmAdxcHq0iT7GpTpua6ix11 MKi+s7FWSvr0r5n0QZvuLFoLK9y7h+Bl4lAfdpDopc1V4NCkeF+/A1LmqBDVc2uR TG4IAfmw7OY4A+tb7sYnXboQBOH3k7bdBUJD31TTEq+WveOdRAzazAjY88sGVt2p ZxlJ6ZPlRchxMmncRqh4HsM0aa+UYCRdwJElmvfOPwtj/X4xcjVCvKRolPpjRL7Y lJTw6WHukvqAf0Fwi7mq7Cpb65oZRC6kPM3OJ/fmN7cFyelO5m4= =GzqM -----END PGP SIGNATURE----- --hrhuntinyslroab3--