From owner-cvs-all@FreeBSD.ORG Mon Mar 12 20:50:35 2007 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 77FE616A405 for ; Mon, 12 Mar 2007 20:50:35 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.244]) by mx1.freebsd.org (Postfix) with ESMTP id 0509913C45B for ; Mon, 12 Mar 2007 20:50:34 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by an-out-0708.google.com with SMTP id c24so1458518ana for ; Mon, 12 Mar 2007 13:50:34 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=i7/G3zHgcw7fMmtBm/+NIdJBrDDPe7urEdw3uR4lVSs6foNPq4jU2q3rRKxSFnkNVm8YqDES2Yhu4BJXKaZSU9U+mgqa4ItxB+Fh+nxdjVsLjlueFkkkMK8Nt9HT063vEH6TpQAli7KsPW54RI5UEnFHkcP3/JnR0iz96yM4X7Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=tpOcye7NYNxoR3zVrZQdVX/F90gWBbXpqBTzEknUl0ScD/fL8mT9K0zvAxJGUAzqt+cdmxcdbR4cDLIz4sUL+mdgyYHsluo/eflYcBj9ZPkIsxVAlE9jHR1YWP8U1+SvcOalAxCKSAiYBgbrLG+DUnGAi3VIGl1SkNILW2eyBD8= Received: by 10.100.120.5 with SMTP id s5mr108716anc.1173732634484; Mon, 12 Mar 2007 13:50:34 -0700 (PDT) Received: by 10.100.191.11 with HTTP; Mon, 12 Mar 2007 13:50:34 -0700 (PDT) Message-ID: <3bbf2fe10703121350k7709dcb0s3ca39a3fb5a6b32b@mail.gmail.com> Date: Mon, 12 Mar 2007 21:50:34 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "John Baldwin" In-Reply-To: <200703121631.11606.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200703092241.l29Mf2Ds062856@repoman.freebsd.org> <20070312200345.GB5688@garage.freebsd.pl> <3bbf2fe10703121317h2fc8d639qfd47def80f5cbe91@mail.gmail.com> <200703121631.11606.jhb@freebsd.org> X-Google-Sender-Auth: 3f4939d07ecde767 Cc: cvs-src@freebsd.org, src-committers@freebsd.org, Pawel Jakub Dawidek , cvs-all@freebsd.org Subject: Re: cvs commit: src/share/man/man9 Makefile condvar.9 lock.9 mi_switch.9 mtx_pool.9 mutex.9 rwlock.9 sleep.9 sleepqueue.9 sx.9 thread_exit.9 src/sys/kern kern_synch.c src/sys/sys mutex.h rwlock.h sleepqueue.h sx.h systm.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2007 20:50:35 -0000 2007/3/12, John Baldwin : > On Monday 12 March 2007 16:17, Attilio Rao wrote: > > 2007/3/12, Pawel Jakub Dawidek : > > > On Mon, Mar 12, 2007 at 03:35:21PM -0400, John Baldwin wrote: > > > > On Monday 12 March 2007 14:56, Pawel Jakub Dawidek wrote: > > > > > On Mon, Mar 12, 2007 at 11:16:23AM -0400, John Baldwin wrote: > > > > > > On Saturday 10 March 2007 15:52, Pawel Jakub Dawidek wrote: > > > > > > > What about something like this: > > > > > > > > > > > > > > #define cv_wait(cv, lock) do { > > > > > > > switch (LO_CLASSINDEX((struct lock_object *)(lock))) { > > > > > > > > > > > > The problem with a cast is you use type checking. Might as well do > this: > > > > > > > > > > > > #define cv_wait(cv, lock) _cv_wait((cv), (struct lock_object > *)(lock)) > > > > > > > > > > This will skip type checking and my version only cast to provide type > > > > > checking, so when you pass some random variable it will give you an > > > > > error. > > > > > > > > Not really, you may pass some garbage and the LO_CLASSINDEX turns out to > be a > > > > mutex. :) You only get a runtime error, not a compile-time one. > > > > Type-checking by the compiler is nice because you get compile-time > errors. > > > > > > I'll get compile-time error, because cv_wait_mtx() takes > > > 'struct condvar *' and 'struct mtx *' as arguments. So even if some > > > garbage returns 1, which turns out to be a mutex, call to cv_wait_mtx() > > > will generate compile-time error. > > > > However, it has another kind of problem we were trying to avoid: the > > first member of the lock you pass should be the struct lock_object. We > > should not deal on the ordering of members for locks. > > > > > But it seems the solution may not be that good if it is not very obvious > > > on a first look. If typeof() thing works, its fine by me, just give me > > > condvar(9) that works with sx(9) locks:) > > > > I think problems with typeof() are 2: > > 1) It requires a serie of if/else if before to call the cv_wait() > > (increase of kernel .text, small slowness, etc.) > > The compiler should optimize those out actually to a single call to > _cv_wait(), just as it does with PCPU_*(). Yes, but it can't optimize the code of choice for different arguments passing. It is noisy extra-code for every call :) Attilio -- Peace can only be achieved by understanding - A. Einstein