From owner-freebsd-threads@FreeBSD.ORG Wed Jun 25 23:14:11 2003 Return-Path: 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 DCDC137B401 for ; Wed, 25 Jun 2003 23:14:11 -0700 (PDT) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4662B44031 for ; Wed, 25 Jun 2003 23:14:11 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from user-2ivfirs.dialup.mindspring.com ([165.247.203.124] helo=mindspring.com) by heron.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19VQ1I-00001W-00; Wed, 25 Jun 2003 23:14:08 -0700 Message-ID: <3EFA8EEB.1E0842D5@mindspring.com> Date: Wed, 25 Jun 2003 23:12:59 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Anurag Chaudhary References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a415d3f081818e80c60f446f9d24cb6968350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c cc: freebsd-threads@freebsd.org cc: julian@elischer.org Subject: Re: semaphores and multithreading X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jun 2003 06:14:12 -0000 Anurag Chaudhary wrote: > I am using sys V semaphores with pthread library on freebsd 5.0 release There are 4 pthread libraries on FreeBSD 5.x-current. Most likely, you are compiling with "-pthread" or something like that. What people are asking you is if you are explicitly linking against a specific threads library, rather than using a compiler/linker option that gives you the library that the system wants you to have. Currently, a manual linkage would require you to specify one of (ignoring the fourth, which is Linux threads from ports): -lc_r <-- historical N:1 threads library -lthr <-- 1:1 threads library -lkse <-- N:M threads library to get threads. The default in 5.0-RELEASE was "-lc_r". If you are using an N:1 threads library, you have only a single kernel blocking context; it operates using a user space call conversion scheduler. This operates for converting a blocking system call into a non-blocking equivalent, and triggering a context switch. System V semaphores do not have non-blocking equivalents for use in implementing a call conversion; therefore, if you call one of these functions, you will end up blocking in the kernel on a blocking primitive, and hanging until the resource becomes available: all threads in the process with the blocking thread will also be blocked. You should convert to using libthr, libkse, or the Linux threads library (which has license issues, relative to the FreeBSD way of looking at things). To use libthr or libkse, you will need to switch your system over from 5.0 to -current. -- Terry