From owner-freebsd-threads@FreeBSD.ORG Wed Aug 30 14:31:39 2006 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6705C16A4DE; Wed, 30 Aug 2006 14:31:39 +0000 (UTC) (envelope-from brian@openss7.org) Received: from gw.openss7.com (gw.openss7.com [142.179.199.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id A145743D46; Wed, 30 Aug 2006 14:31:17 +0000 (GMT) (envelope-from brian@openss7.org) Received: from ns.pigworks.openss7.net (IDENT:85NxUy40jG/pnmkz0q4mPRCJwzssz39v@ns1.evil.openss7.net [192.168.9.1]) by gw.openss7.com (8.11.6/8.11.6) with ESMTP id k7UEVGG09991; Wed, 30 Aug 2006 08:31:16 -0600 Received: (from brian@localhost) by ns.pigworks.openss7.net (8.11.6/8.11.6) id k7UEVAs24535; Wed, 30 Aug 2006 08:31:10 -0600 To: brian@ns.pigworks.openss7.net Path: edtnps84!newsfeed2.telusplanet.net!newsfeed.telus.net!newsfeed.news2me.com!headwall.stanford.edu!newsreader.wustl.edu!not-for-mail From: Andriy Gapon Newsgroups: comp.soft-sys.ace Date: Wed, 30 Aug 2006 17:22:52 +0300 Organization: Washington University in St. Louis Lines: 50 Message-ID: NNTP-Posting-Host: postmark.cse.wustl.edu Mime-Version: 1.0 Content-Type: text/plain; charset=KOI8-U Content-Transfer-Encoding: 7bit X-Trace: newsreader.wustl.edu 1156947796 28759 128.252.166.5 (30 Aug 2006 14:23:16 GMT) X-Complaints-To: usenet@newsreader.wustl.edu NNTP-Posting-Date: Wed, 30 Aug 2006 14:23:16 +0000 (UTC) To: freebsd-threads@freebsd.org, ace-users@cse.wustl.edu X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on postmark.cse.wustl.edu X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed version=3.1.4 X-Original-To: ace-users@cse.wustl.edu Delivered-To: ace-users@cse.wustl.edu User-Agent: Thunderbird 1.5.0.5 (X11/20060801) X-BeenThere: ace-users@mail.cse.wustl.edu X-Mailman-Version: 2.1.8 Precedence: list Xref: news.telusplanet.net comp.soft-sys.ace:95828 Cc: Sergey Matveychuk Subject: [ace-users] ace/freebsd: THR_NEW_LWP problem with libpthread/pthread_setconcurrency X-BeenThere: freebsd-threads@freebsd.org List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Aug 2006 14:31:39 -0000 ACE VERSION: 5.5.1 (from FreeBSD port: ace-5.5.1) HOST MACHINE and OPERATING SYSTEM: FreeBSD 6.1-RELEASE-p2 i386 (uniprocessor) COMPILER NAME AND VERSION (AND PATCHLEVEL): gcc version 3.4.4 [FreeBSD] 20050518 (system compiler) libpthread is used as threading library AREA/CLASS/EXAMPLE AFFECTED: ACE threads DOES THE PROBLEM AFFECT: EXECUTION - this is a run-time problem SYNOPSIS: Can not create threads with THR_NEW_LWP flag. DESCRIPTION: ACE_Thread_Manager::spawn(..., THR_NEW_LWP) fails with EAGAIN. It seems that this happens because when creating such threads ACE calls pthread_setconcurrency with incrementally increasing concurrency levels. pthread_setconcurrency of libpthread in turn seems to call kse_create() which fails with EPROCLIM. As I understand this happens because kernel does not allow to have more KSE-s per process as there are processors. This problem is quite noticeable with ACE because THR_NEW_LWP is present in default flags in many places. REPEAT BY: Running any ACE-based program that spawns threads with THR_NEW_LWP and linked to libpthead. SAMPLE FIX/WORKAROUND: Straightforward workaround is to explicitly pass thread flags everywhere and not use THR_NEW_LWP. Maybe this could be patched in ACE sources as a part of FreeBSD port patch step. IMHO, better fixes would be: 1. make ACE_Thread_Manager::spawn() more robust with respect to pthread_setconcurrency() failing with EAGAIN. 2. make FreeBSD libpthread dumb-happy in pthread_setconcurrency(), i.e pretend to always succeed. AFAIK, POSIX leaves it up to implementations to interpret concurrency levels, so making any level be equivalent to default level should be OK. -- Andriy Gapon