From owner-freebsd-java@FreeBSD.ORG Thu Nov 11 19:53:17 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E3C9316A4CE for ; Thu, 11 Nov 2004 19:53:17 +0000 (GMT) Received: from e-card.bg (FaiLurE.e-card.bg [212.91.167.2]) by mx1.FreeBSD.org (Postfix) with SMTP id 1B30843D3F for ; Thu, 11 Nov 2004 19:53:13 +0000 (GMT) (envelope-from mcgregory@e-card.bg) Received: (qmail 34350 invoked from network); 11 Nov 2004 19:50:46 -0000 Received: from unknown (HELO ?213.137.61.196?) (213.137.61.196) by mail.e-card.bg with SMTP; 11 Nov 2004 19:50:46 -0000 From: Martin Grigorov To: freebsd-java@freebsd.org In-Reply-To: References: <1100119160.700.13.camel@martin151> Content-Type: text/plain Organization: Home Message-Id: <1100209986.683.49.camel@martin151> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 11 Nov 2004 21:53:07 +0000 Content-Transfer-Encoding: 7bit cc: Ronald Klop Subject: Re: Thread's type X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: mcgregory@e-card.bg List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2004 19:53:18 -0000 On Thu, 2004-11-11 at 14:36, Ronald Klop wrote: > On Wed, 10 Nov 2004 20:39:21 +0000, Martin Grigorov > wrote: > > > Hi all, > > > > I want to ask what type are Java threads in FreeBSD - green or native ? > > I'm using FreeBSD 5.3 and jdk 1.4.2 from ports, actually > > /usr/ports/jdk14. > > > > I am a little bit confused: a sysctl entry > > "kern.threads.max_threads_per_proc" says that one process can run max > > 1500 threads. But I wrote test and it crashes with: > > 'Exception in thread "main" java.lang.OutOfMemoryError: unable to create > > new native thread', after starting ~ 8300 threads in the Virtual > > Machine. > > So it sais "native" in the exception, but they are much more than 1500. > > Java uses native threads. > > About the 'kern.threads.max_threads_per_proc' limit: > The default thread support of FreeBSD 5 (libpthread) doesn't map userspace > threads and kernel thread 1:1. > As long as a thread isn't executing in a part of the kernel it doesn't use > kernel resources. > Use top -H to see all threads that are known to the kernel. > > If you put this in /etc/libmap.conf you will use a 1:1 thread library and > your program will give (the expected) errors around 1500 threads. > > libpthread.so.1 libthr.so.1 # Everything that uses 'libpthread' > libpthread.so libthr.so # now uses libthr. > > libc_r.so.5 libthr.so.1 # Everything that uses 'libc_r' > libc_r.so libthr.so # now uses 'libthr' > > Because the N:M thread mapping a program can switch between threads > without kernel overhead. > > Ronald. Hi Thanks for the response. Did you know how can I manage the maximum number of userland threads at all (using libpthread library), or in my case the number of threads in java process. I know about the option -Xss, but this sets the maximum stack size, not the number of threads that could be started. Even more "man java" says that: "The default stack size is determined by the Linux operating system upon which the Java platform is running." What is the default in FreeBSD ? Do somebody know when we will have /usr/ports/jdk15 ( or maybe /usr/ports/jdk5 :) )? I have installed linux-sun-jdk15, but it crashes with SIGSYS, even when I run it within Linux's bash2.