From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 19 11:01:50 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 569011065692 for ; Tue, 19 Jan 2010 11:01:50 +0000 (UTC) (envelope-from bvgastel@bitpowder.com) Received: from rustug.science.ru.nl (rustug.science.ru.nl [131.174.16.158]) by mx1.freebsd.org (Postfix) with ESMTP id 06BB08FC1B for ; Tue, 19 Jan 2010 11:01:48 +0000 (UTC) Received: from smeltpunt.science.ru.nl (smeltpunt.science.ru.nl [131.174.16.145]) by rustug.science.ru.nl (8.13.7/5.31) with ESMTP id o0JAiDf6007069 for ; Tue, 19 Jan 2010 11:44:14 +0100 (MET) Received: from [10.0.1.2] (shadowfax.bitpowder.com [145.99.244.126]) (authen=bernardg) by smeltpunt.science.ru.nl (8.13.7/5.31) with ESMTP id o0JAi9WN013448 for ; Tue, 19 Jan 2010 11:44:09 +0100 (MET) From: Bernard van Gastel Content-Type: multipart/signed; boundary=Apple-Mail-1--24675925; protocol="application/pkcs7-signature"; micalg=sha1 Date: Tue, 19 Jan 2010 11:44:08 +0100 Message-Id: <71A129DC-68A0-46C3-956D-C8AFF1BA29E1@bitpowder.com> To: freebsd-hackers@freebsd.org Mime-Version: 1.0 (Apple Message framework v1077) X-Mailer: Apple Mail (2.1077) X-Spam-Score: 0.001 () BAYES_50 X-Scanned-By: MIMEDefang 2.63 on 131.174.16.145 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: pthread_{mutex,cond} & fifo/starvation/scheduling policy 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: Tue, 19 Jan 2010 11:01:50 -0000 --Apple-Mail-1--24675925 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi everyone, I'm curious to the exact scheduling policy of POSIX threads in relation = to mutexes and conditions. If there are two threads (a & b), both with = the following code: while (1) { pthread_mutex_lock(mutex); ... pthread_mutex_unlock(mutex); } What is the scheduling policy of the different thread libraries? Are = both threads getting an equal amount of time? Are there no starvation = issues (are they executed in alternating turns)? (a test program of mine = indicates that libpthread and libthr both have starvation issues, in = contrary to Mac OS X 10.6) Also, I'm interested in the scheduling behaviour in combination with = pthread_cond. Get a signalled thread priority to relock the mutex it is = waiting on, or is the relock operation just a normal lock operation and = is handled as such? (so different kind of starvation issues can occur in = the latter case) I have googled extensively and browsed the libthr sources, but can't = find the specs that I'm looking for. Any help will appreciated. With regards, Bernard van Gastel= --Apple-Mail-1--24675925--