From owner-freebsd-threads@FreeBSD.ORG Sat Apr 28 12:50:58 2012 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39C8D106566C for ; Sat, 28 Apr 2012 12:50:58 +0000 (UTC) (envelope-from chris.hall@highwayman.com) Received: from anchor-post-1.mail.demon.net (anchor-post-1.mail.demon.net [195.173.77.132]) by mx1.freebsd.org (Postfix) with ESMTP id EE8D78FC14 for ; Sat, 28 Apr 2012 12:50:57 +0000 (UTC) Received: from [80.177.246.130] (helo=hestia.halldom.com) by anchor-post-1.mail.demon.net with esmtp (Exim 4.69) id 1SO71B-0006MB-iE for freebsd-threads@freebsd.org; Sat, 28 Apr 2012 12:44:53 +0000 Received: from hyperion.halldom.com ([80.177.246.170] helo=HYPERION) by hestia.halldom.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1SO719-0002Ti-H8 for freebsd-threads@freebsd.org; Sat, 28 Apr 2012 12:44:51 +0000 From: "'Chris Hall'" Sender: "Chris Hall" To: Date: Sat, 28 Apr 2012 13:44:46 +0100 Organization: Highwayman Message-ID: <056201cd253c$b43a0860$1cae1920$@highwayman.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac0lPKnGhmxEP7zpSCa0p5c0+tQlcw== Content-Language: en-gb Subject: Trying to set PTHREAD_SCOPE_SYSTEM X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Apr 2012 12:50:58 -0000 For my application (a BGP daemon) I think I should be setting all its pthreads to PTHREAD_SCOPE_SYSTEM. (This may be where I am going wrong, of course, but bear with me.) I have studied the POSIX specifications and the FreeBSD man pages, and am stuck. pthread_init_attr() is supposed to give me the default settings for everything, including the scope and PTHREAD_INHERIT_SCHED/_EXPLICIT_SCHED. First difficulty: if it is PTHREAD_INHERIT_SCHED, what are the scope, schedpolicy and schedparam set to ? Second difficulty: if I set PTHREAD_EXPLICIT_SCHED, will that change the scope/policy/param to the defaults, or leave them unchanged (in which case are they the appropriate defaults) ? Or, am I really expected to set all of scope/policy/param if I override a default PTHREAD_INHERIT_SCHED ? (If the default is PTHREAD_SCOPE_SYSTEM, am I all set having cleared PTHREAD_INHERIT_SCHED ?) Third difficulty: if I set PTHREAD_SCOPE_SYSTEM and the default is PTHREAD_SCOPE_PROCESS, do I also need to set policy/param ? If so, where do I find suitable default policy/param ? (I could copy the policy/param from the main thread... but will that be suitable for PTHREAD_SCOPE_SYSTEM ?) Fourth difficulty: if I dick about with scope/policy/param, will I need special privileges (root, say) ? Fifth difficulty: it is clearly easiest to leave this whole thing alone and ignore pthread_attr_t altogether. Is there a way to set PTHREAD_SCOPE_SYSTEM as the default for a given application from the outside ? POSIX appears to define a bunch of stuff in this area... but so much is implementation defined, or simply not defined I imagine (a) 99.9% of threaded applications do not attempt to use pthread_attr_t at all, and (b) that somewhere each implementation will define what it does ? Help !! Thanks, Chris