From owner-freebsd-java@FreeBSD.ORG Thu Nov 11 14:37:02 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 50F8016A4CE for ; Thu, 11 Nov 2004 14:37:02 +0000 (GMT) Received: from smtp16.wxs.nl (smtp16.wxs.nl [195.121.6.39]) by mx1.FreeBSD.org (Postfix) with ESMTP id EB1B543D55 for ; Thu, 11 Nov 2004 14:37:01 +0000 (GMT) (envelope-from ronald-freebsd8@klop.yi.org) Received: from ronald.echteman.nl (ip51cdc5d2.speed.planet.nl [81.205.197.210]) by smtp16.wxs.nlSMTP id <0I7000J7JR9OX3@smtp16.wxs.nl> for freebsd-java@freebsd.org; Thu, 11 Nov 2004 15:37:00 +0100 (CET) Received: (qmail 3916 invoked from network); Thu, 11 Nov 2004 14:37:00 +0000 Received: from unknown (HELO laptop.thuis.klop.ws) (192.168.1.4) by ronald.echteman.nl with SMTP; Thu, 11 Nov 2004 14:37:00 +0000 Received: (qmail 51548 invoked from network); Thu, 11 Nov 2004 14:36:56 +0000 Received: from localhost.thuis.klop.ws (HELO smtp.local) (127.0.0.1) by localhost.thuis.klop.ws with SMTP; Thu, 11 Nov 2004 14:36:56 +0000 Date: Thu, 11 Nov 2004 15:36:53 +0100 From: Ronald Klop In-reply-to: <1100119160.700.13.camel@martin151> To: mcgregory@e-card.bg, freebsd-java@freebsd.org Message-id: MIME-version: 1.0 Content-type: text/plain; format=flowed; delsp=yes; charset=iso-8859-1 Content-transfer-encoding: 7BIT User-Agent: Opera M2/7.54 (FreeBSD, build 751) References: <1100119160.700.13.camel@martin151> Subject: Re: Thread's type X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2004 14:37:02 -0000 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. -- Ronald Klop, Amsterdam, The Netherlands