From owner-freebsd-hackers@FreeBSD.ORG Mon Jun 27 04:19:59 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6523116A41C for ; Mon, 27 Jun 2005 04:19:59 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FA8443D48 for ; Mon, 27 Jun 2005 04:19:58 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id j5R4JwKe091123; Sun, 26 Jun 2005 23:19:58 -0500 (CDT) (envelope-from dan) Date: Sun, 26 Jun 2005 23:19:58 -0500 From: Dan Nelson To: Pablo Mora Message-ID: <20050627041958.GB51206@dan.emsphone.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.9i Cc: freebsd-hackers@freebsd.org Subject: Re: problem handling POSIX thread on FreeBSD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2005 04:19:59 -0000 In the last episode (Jun 26), Pablo Mora said: > int main() { > .... > if(pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) != 0) > /* handler */ > .... > } > > $ gcc taller.c -pthread > $ ./a.out > pthread_attr_setscope: Unknown error: 0 > $ > > PTHREAD_SCOPE_SYSTEM fail on freebsd ? The libc_r and libthr threads libraries do not support PTHREAD_SCOPE_SYSTEM. The standard does not require support for both PTHREAD_SCOPE_PROCESS and PTHREAD_SCOPE_SYSTEM, so it's better if you don't treat failure of pthread_attr_setscope() as fatal to the program. If you're running FreeBSD 4.0, your only choice of threads library is libc_r. Also note that the pthread_attr_*() functions are special in that they do not set the errno variable. They return their error code, so you need to do something like: rv = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); if (rv && rv != ENOTSUP) handle_error(); -- Dan Nelson dnelson@allantgroup.com