From owner-freebsd-stable@FreeBSD.ORG Thu May 15 00:40:37 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BD65106568A; Thu, 15 May 2008 00:40:37 +0000 (UTC) (envelope-from davids@webmaster.com) Received: from mail1.webmaster.com (mail1.webmaster.com [216.152.64.169]) by mx1.freebsd.org (Postfix) with ESMTP id EC26A8FC0C; Thu, 15 May 2008 00:40:36 +0000 (UTC) (envelope-from davids@webmaster.com) Received: from however by webmaster.com (MDaemon.PRO.v8.1.3.R) with ESMTP id md50002051997.msg; Wed, 14 May 2008 17:30:53 -0700 From: "David Schwartz" To: , Date: Wed, 14 May 2008 17:29:30 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal In-Reply-To: <482B0297.2050300@icyb.net.ua> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Authenticated-Sender: joelkatz@webmaster.com X-Spam-Processed: mail1.webmaster.com, Wed, 14 May 2008 17:30:53 -0700 (not processed: message from trusted or authenticated source) X-MDRemoteIP: 206.171.168.138 X-Return-Path: davids@webmaster.com X-MDAV-Processed: mail1.webmaster.com, Wed, 14 May 2008 17:30:54 -0700 Cc: Subject: RE: thread scheduling at mutex unlock X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: davids@webmaster.com List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 May 2008 00:40:37 -0000 > I am trying the small attached program on FreeBSD 6.3 (amd64, > SCHED_4BSD) and 7-STABLE (i386, SCHED_ULE), both with libthr as = threads > library and on both it produces "BROKEN" message. >=20 > I compile this program as follows: > cc sched_test.c -o sched_test -pthread >=20 > I believe that the behavior I observe is broken because: if thread #1 > releases a mutex and then tries to re-acquire it while thread #2 was > already blocked waiting on that mutex, then thread #1 should be = "queued" > after thread #2 in mutex waiter's list. >=20 > Is there any option (thread scheduler, etc) that I could try to = achieve > "good" behavior? >=20 > P.S. I understand that all this is subject to (thread) scheduler = policy, > but I think that what I expect is more reasonable, at least it is more > reasonable for my application. >=20 > --=20 > Andriy Gapon Are you out of your mind?! You are specifically asking for the absolute = worst possible behavior! If you have fifty tiny things to do on one side of the room and fifty = tiny things to do on the other side, do you cross the room after each = one? Of course not. That would be *ludicrous*. If you want/need strict alternation, feel free to code it. But it's the = maximally inefficient scheduler behavior, and it sure as hell had better = not be the default. DS