From owner-freebsd-questions@FreeBSD.ORG Tue Oct 7 10:35:18 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8F27106568E for ; Tue, 7 Oct 2008 10:35:18 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from QMTA01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [76.96.30.16]) by mx1.freebsd.org (Postfix) with ESMTP id 9BFB48FC0C for ; Tue, 7 Oct 2008 10:35:18 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from OMTA02.emeryville.ca.mail.comcast.net ([76.96.30.19]) by QMTA01.emeryville.ca.mail.comcast.net with comcast id PmWB1a0050QkzPwA1malCV; Tue, 07 Oct 2008 10:34:45 +0000 Received: from koitsu.dyndns.org ([69.181.141.110]) by OMTA02.emeryville.ca.mail.comcast.net with comcast id PmbH1a0052P6wsM8NmbHi0; Tue, 07 Oct 2008 10:35:18 +0000 X-Authority-Analysis: v=1.0 c=1 a=NnI8htzV5zcA:10 a=QwHlaQfUiooA:10 a=QycZ5dHgAAAA:8 a=uhHEUSstDGeUS_31WOkA:9 a=_5dDWAlWGf_oaSuCDP9G8XqH_ygA:4 a=EoioJ0NPDVgA:10 a=LY0hPdMaydYA:10 Received: by icarus.home.lan (Postfix, from userid 1000) id 471EBC9419; Tue, 7 Oct 2008 03:35:17 -0700 (PDT) Date: Tue, 7 Oct 2008 03:35:17 -0700 From: Jeremy Chadwick To: Rajeshwar Patil Message-ID: <20081007103517.GA46537@icarus.home.lan> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Ramachandran Sathyanarayanan , freebsd-questions@freebsd.org Subject: Re: sleep is not working to avoid starvation among threads of same priority X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Oct 2008 10:35:18 -0000 On Tue, Oct 07, 2008 at 03:34:41PM +0530, Rajeshwar Patil wrote: > I have two threads of same priority lets say thread A and thread B, > thread A is starving since thread B has got a for loop of size 100k. > So, to avoid starvation I am processing 1000 iterations of for > loop(that of thread B) in one batch and giving sleep of 1ms, but still > thread A is starving. If I increase the batch size used in for loop > from 1k to 10k then starvation of thread A is little less whereas it > should be more as Im increasing processing time of thread B. I tried > various combinations of sleeps and batches, but I couldnt solve the > starvation of thread A. > > Is the sleep right solution? > > I will be grateful if someone could answer on this. This might be a question for freebsd-hackers, which is more developer-oriented than -questions. -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |