From owner-freebsd-threads@FreeBSD.ORG Wed Mar 29 09:39:50 2006 Return-Path: X-Original-To: threads@freebsd.org 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 6CA6516A422; Wed, 29 Mar 2006 09:39:50 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 18F2843D45; Wed, 29 Mar 2006 09:39:50 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from [127.0.0.1] (root@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k2T9dk1O068079; Wed, 29 Mar 2006 09:39:48 GMT (envelope-from davidxu@freebsd.org) Message-ID: <442A55EB.9060009@freebsd.org> Date: Wed, 29 Mar 2006 17:39:55 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060302 X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-1?Q?Dag-Erling_Sm=F8rgrav?= References: <86slp1u4qb.fsf@xps.des.no> <442A466A.9040506@freebsd.org> <861wwlehvg.fsf@xps.des.no> In-Reply-To: <861wwlehvg.fsf@xps.des.no> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: threads@freebsd.org, jeff@freebsd.org Subject: Re: libthr cleanup X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2006 09:39:50 -0000 Dag-Erling Smørgrav wrote: > In effect, the wait / wake operations implement a condition variable. > You should not use the same struct (or type) to describe the condition > variable as the one you use to describe a mutex. > > Condition variables are always used in conjunction with a mutex. The > mutex must be passed to the wait function so it can be unlocked while > the waiting thread waits. It must be held by the thread calling the > wake method. Neither the existing interface nor the one you propose > do this. > You are talking about how to use it, not how to implement it. > You cannot "wait for an integer to be changed" (at least not without > using hardware debugging facilities), and that is not what > UMTX_OP_WAIT does. It is a botched condition variable. It waits for > another thread to perform an UMTX_OP_WAKE operation with the correct > arguments; the fact that an integer has changed is incidental, and the > test for that change could be implemented in userland: look up > condition variables in any good CS textbook and you will see an > example of this, likely in the guise of a sample message queue (or > mailbox) implementation. > again, there are many ways to implement it, I think you are talking about how to use it, not how to implement it. > I can understand wanting to move the check into the kernel to avoid > spurious context switches, but it has to be done right. > > >> you >>should check source code before talking a lot, > > > That is precisely what I have done. > > >> saying that you doubt >>the UMTX_OP_WAIT and UMTX_OP_WAKE's correctness is not professional, >>there are users using libthr in daily work and stress testing had >>been done. >>I have put lots of work and time on libthr, I know the problems, >>though the _umtx interface is a bit ulgly because it was unclear >>when it was being designed, but I don't think it really hurt you or >>other people, it can be fixed in few days, I just was hesitating to >>add the new interfaces. > > > The amount of work you have put into libthr and its importance to your > self-esteem do not guarantee its correctness. What is unprofessional > here is 1) the quality of your code and 2) your refusal to consider > that I might have a point. > > DES I don't trust you, I don't think your work is useful to me, you are rushing, and command everyone to catch up with you, but we have life, wife, and children, I am old, I should leave FreeBSD. David Xu