From owner-freebsd-java@FreeBSD.ORG Sun Sep 16 03:05:09 2007 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 894F116A417; Sun, 16 Sep 2007 03:05:09 +0000 (UTC) (envelope-from lists@intricatesoftware.com) Received: from mail1.intricatesoftware.com (cl-18.ewr-01.us.sixxs.net [IPv6:2001:4830:1200:11::2]) by mx1.freebsd.org (Postfix) with ESMTP id 2348813C457; Sun, 16 Sep 2007 03:05:09 +0000 (UTC) (envelope-from lists@intricatesoftware.com) Received: from seraph.intricatesoftware.com (relay@localhost.intricatesoftware.com [IPv6:::1]) by mail1.intricatesoftware.com (8.14.1/8.13.4) with ESMTP id l8G355nK021833; Sat, 15 Sep 2007 23:05:06 -0400 (EDT) Received: from seraph.intricatesoftware.com (truk@localhost.intricatesoftware.com [127.0.0.1]) by seraph.intricatesoftware.com (8.14.1/8.14.1) with ESMTP id l8G356Zp030484; Sat, 15 Sep 2007 23:05:06 -0400 (EDT) Received: (from truk@localhost) by seraph.intricatesoftware.com (8.14.1/8.14.1/Submit) id l8G356SB025431; Sat, 15 Sep 2007 23:05:06 -0400 (EDT) X-Authentication-Warning: seraph.intricatesoftware.com: truk set sender to lists@intricatesoftware.com using -f From: Kurt Miller To: freebsd-java@freebsd.org Date: Sat, 15 Sep 2007 23:05:05 -0400 User-Agent: KMail/1.9.7 References: <46EC1B55.4060202@FreeBSD.org> <200709152250.50879.kurt@intricatesoftware.com> In-Reply-To: <200709152250.50879.kurt@intricatesoftware.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200709152305.06116.lists@intricatesoftware.com> X-SMTP-Vilter-Version: 1.3.6 X-SMTP-Vilter-Virus-Backend: clamd X-SMTP-Vilter-Status: clean X-SMTP-Vilter-clamd-Virus-Status: clean X-Spamd-Symbols: ALL_TRUSTED X-SMTP-Vilter-Spam-Backend: spamd X-Spam-Score: -1.4 X-Spam-Threshold: 5.0 X-Spam-Probability: -0.3 X-Its-A-Nuisance: This is spam X-SMTP-Vilter-Unwanted-Backend: attachment X-SMTP-Vilter-attachment-Unwanted-Status: clean Cc: Kris Kennaway , performance@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: kurt@intricatesoftware.com List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Sep 2007 03:05:09 -0000 On Saturday 15 September 2007 10:50:50 pm Kurt Miller wrote: > The following are programs I wrote when I isolated the problem. > If the c program runs ok on 7.0 for both single cpu and mp then > remove the os_sleep() and try the java program. If that works too > then you're clear to make the os_sleep() hack only apply to < > 7.0 and still be able to pass the certification tests. Sorry copy/paste glitch. He is the c program again: #include #include #include #include #include #include #include #include volatile int init=0; volatile int interrupt=0; static void * yielder(void *arg) { init = 1; while (1) { pthread_yield(); } } static void sighandler(int sig) { interrupt = 1; printf("sighandler\n"); } static void waitForInit() { struct timespec t, rt; while (init == 0) { t.tv_sec = 0; t.tv_nsec = 100000; nanosleep(&t, &rt); } } static void waitForInterrupt() { struct timespec t, rt; while (interrupt == 0) { t.tv_sec = 0; t.tv_nsec = 100000; nanosleep(&t, &rt); } } int main(int argc, char *argv[]) { pthread_t yldr; pthread_attr_t attr; struct sigaction act; /* Install a signal handler for SIGUSR1 */ sigemptyset (&act.sa_mask); sigaddset (&act.sa_mask, SIGUSR1); act.sa_handler = sighandler; act.sa_flags = 0; sigaction (SIGUSR1, &act, NULL); pthread_attr_init(&attr); pthread_attr_setschedpolicy(&attr, SCHED_FIFO); pthread_create(&yldr, &attr, yielder, NULL); pthread_setprio(yldr, 16); waitForInit(); if(pthread_kill(yldr, SIGUSR1) != 0) printf("pthread_kill failed with errno = %d\n", errno); waitForInterrupt(); }