Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 2003 23:12:59 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Anurag Chaudhary <chaudharyanurag@hotmail.com>
Cc:        julian@elischer.org
Subject:   Re: semaphores and multithreading
Message-ID:  <3EFA8EEB.1E0842D5@mindspring.com>
References:  <Law9-F99d5CxSPs5Pd60000021f@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3EFA8EEB.1E0842D5>