From owner-freebsd-java@FreeBSD.ORG Sun Sep 16 04:47:45 2007 Return-Path: Delivered-To: java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EEDF916A41B; Sun, 16 Sep 2007 04:47:42 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 0450213C481; Sun, 16 Sep 2007 04:47:41 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.1/8.14.1/NETPLEX) with ESMTP id l8G4leid001906; Sun, 16 Sep 2007 00:47:40 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.netplex.net [204.213.176.10]); Sun, 16 Sep 2007 00:47:40 -0400 (EDT) Date: Sun, 16 Sep 2007 00:47:40 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Kurt Miller In-Reply-To: <200709152250.50879.kurt@intricatesoftware.com> Message-ID: References: <46EC1B55.4060202@FreeBSD.org> <200709152250.50879.kurt@intricatesoftware.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: java@freebsd.org, Kris Kennaway , performance@freebsd.org, freebsd-java@freebsd.org Subject: Re: Massive performance loss from OS::sleep hack X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Sep 2007 04:47:45 -0000 On Sat, 15 Sep 2007, Kurt Miller wrote: > > Hello Kris, > > I recall why I added the os_sleep() call. While working on the certification > testing one of the JCK tests was deadlocking. The test itself was faulty in > that it created a high priority thread in a tight yield loop. Since > pthread_yield() on a single processor system will not yield to lower > priority threads, the higher priority thread effectively blocked the > lower priority thread from running and the test deadlocked. > > I filed a formal appeal to have the JCK test corrected. However since the > api states: > > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#yield() > "Causes the currently executing thread object to temporarily pause > and allow other threads to execute." > > the appeal was denied. I further argued that many publications written > by or or-authored by Sun employees state that Thread.yield() can not > be relied upon in this fashion: [ ... ] It's odd that Sun would take this position since the POSIX behavior for sched_yield() is: The sched_yield() function shall force the running thread to relinquish the processor until it again becomes the head of its thread list. It takes no arguments. The "its thread list" mentioned above is the list of threads for its given priority. POSIX has a notion of a list of threads for each given priority; in SCHED_RR and SCHED_FIFO scheduling the higher priority threads will always run before lower priority threads. Sun's defined Java behavior, or their interpretation, of Thread.yield() is not obtainable on a POSIX compliant system using sched_yield() (or pthread_yield()). Even using scope system threads or libthr, the kernel scheduler should run the higher priority threads before lower priority threads. I suspect that Sun will eventually be forced to change their documented behavior for Thread.yield(). -- DE