From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@9fans.net Date: Mon, 23 Mar 2009 01:52:45 +0100 From: cinap_lenrek@gmx.de In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-mpskxtmwvbhxhrgrggohomiqkp" Subject: Re: [9fans] fossil periodic thread does zero sleep() Topicbox-Message-UUID: c206131a-ead4-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-mpskxtmwvbhxhrgrggohomiqkp Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit I have no idea what HZ is used on my kernel, but i think i understand the problem now. I still can reproduce it with this: double t, ct, ts; ct = nsec()*1e-6; t = ct + msec; for(;;){ ts = t - ct; sleep(ts); ct = nsec()*1e-6; if(t <= ct){ t += msec; } } The problem is that when sleep is a little bit too fast on every round, t will never catch up with ct. so it sleeps shorter and shorter until t - ct < 1. It all works when changing t += msec to t = ct + msec. It may still do a zero sleep, but the error will not add up. making new kernel... -- cinap --upas-mpskxtmwvbhxhrgrggohomiqkp Content-Type: message/rfc822 Content-Disposition: inline Return-Path: <9fans-bounces+cinap_lenrek=gmx.de@9fans.net> X-Flags: 0000 Delivered-To: GMX delivery to cinap_lenrek@gmx.de Received: (qmail invoked by alias); 23 Mar 2009 00:30:10 -0000 Received: from gouda.swtch.com (EHLO gouda.swtch.com) [67.207.142.3] by mx0.gmx.net (mx104) with SMTP; 23 Mar 2009 01:30:10 +0100 Received: from localhost ([127.0.0.1] helo=gouda.swtch.com) by gouda.swtch.com with esmtp (Exim 4.67) (envelope-from <9fans-bounces@9fans.net>) id 1LlXzy-00053o-Ne; Mon, 23 Mar 2009 00:26:38 +0000 Received: from ladd.quanstro.net ([69.55.170.73]) by gouda.swtch.com with esmtp (Exim 4.67) (envelope-from ) id 1LlXzw-00053j-Ji for 9fans@9fans.net; Mon, 23 Mar 2009 00:26:37 +0000 Message-ID: From: erik quanstrom Date: Sun, 22 Mar 2009 20:24:17 -0400 To: 9fans@9fans.net In-Reply-To: <99a6e3a7cd4a1a6da9d06b97ddff4e37@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] fossil periodic thread does zero sleep() X-BeenThere: 9fans@9fans.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.9fans.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: 9fans-bounces@9fans.net Errors-To: 9fans-bounces+cinap_lenrek=gmx.de@9fans.net X-GMX-Antivirus: 0 (no virus found) X-GMX-Antispam: 0 (Mail was not recognized as spam) X-GMX-UID: J+rxfi10bGI0JIYxzmRny1dncmZ1ZlyQ what is your HZ set at? after chasing a few bugs like this, i've set HZ=1000. actually i first saw the idea in sam hopins' work there's no performance drag and 1 ms sleeps do actually sleep. - erik --upas-mpskxtmwvbhxhrgrggohomiqkp--