From owner-cvs-src@FreeBSD.ORG Sat Mar 10 12:13:32 2007 Return-Path: X-Original-To: cvs-src@freebsd.org Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EDD8816A401 for ; Sat, 10 Mar 2007 12:13:31 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from ik-out-1112.google.com (ik-out-1112.google.com [66.249.90.179]) by mx1.freebsd.org (Postfix) with ESMTP id 7672713C474 for ; Sat, 10 Mar 2007 12:13:31 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by ik-out-1112.google.com with SMTP id c21so1147120ika for ; Sat, 10 Mar 2007 04:13:30 -0800 (PST) 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=dRb1fZA6woUexl1jxZt/X2wT3AKHlL5giZ68Akgbl0hugjOFtAaI35+TksmZBmMXzioaNbedcKIPYcSJvqUaBuq/TScayie+lIlGf3PuZ3iBJREc/ookTbGSwcflOkcwrVFMy4lKoI+HlrTbTzTIj4ZIsYYIiWYVyRYDyAhbHI0= 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=oiOGfs//uCM3GsATj6tt4MQHf7QQ1HC7A9x1U3f3sPyDWO4Ch+cV83O5fAr8ahS03rPbOJFlS45CBB3CzZlIFdOiSlYQaJQA/K/CBzyEyP6I7d9koLCoqHwdnCwJfjNuoXkJSD3im4KNf8g4wy4RavN3XfoNHqG77Ey+QlQTNDQ= Received: by 10.70.89.1 with SMTP id m1mr5250707wxb.1173527067166; Sat, 10 Mar 2007 03:44:27 -0800 (PST) Received: by 10.100.191.11 with HTTP; Sat, 10 Mar 2007 03:44:26 -0800 (PST) Message-ID: <3bbf2fe10703100344w1f2464f0q68086a5af7c4f63c@mail.gmail.com> Date: Sat, 10 Mar 2007 12:44:26 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "John Baldwin" In-Reply-To: <200703091747.07617.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> <200703091747.07617.jhb@freebsd.org> X-Google-Sender-Auth: 07735e7855f479c0 Cc: cvs-src@freebsd.org, src-committers@freebsd.org, 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-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2007 12:13:32 -0000 2007/3/9, John Baldwin : > On Friday 09 March 2007 17:41, John Baldwin wrote: > > jhb 2007-03-09 22:41:01 UTC > > > > FreeBSD src repository > > > > Modified files: > > 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 > > sys/kern kern_synch.c > > sys/sys mutex.h rwlock.h sleepqueue.h sx.h > > systm.h > > Log: > > Allow threads to atomically release rw and sx locks while waiting for an > > event. Locking primitives that support this (mtx, rw, and sx) now each > > include their own foo_sleep() routine. > > - Rename msleep() to _sleep() and change it's 'struct mtx' object to a > > 'struct lock_object' pointer. _sleep() uses the recently added > > lc_unlock() and lc_lock() function pointers for the lock class of the > > specified lock to release the lock while the thread is suspended. > > - Add wrappers around _sleep() for mutexes (mtx_sleep()), rw locks > > (rw_sleep()), and sx locks (sx_sleep()). msleep() still exists and > > is now identical to mtx_sleep(), but it is deprecated. > > - Rename SLEEPQ_MSLEEP to SLEEPQ_SLEEP. > > - Rewrite much of sleep.9 to not be msleep(9) centric. > > - Flesh out the 'RETURN VALUES' section in sleep.9 and add an 'ERRORS' > > section. > > - Add __nonnull(1) to _sleep() and msleep_spin() so that the compiler will > > warn if you try to pass a NULL wait channel. The functions already have > > a KASSERT to that effect. > > I don't have a date set for removing msleep(), esp. given it's wide use. > I would like to remove it and all the spl*() functions in 8.0 if we can > swing it. > > I also have patches to let condition variables work with rwlocks and sx > locks, but the current implementation results in an API "explosion" > since each of the cv_*wait*() functions grows a cv_*wait*_rw() version for > rwlocks and a cv_*waut*_sx() version for use with sx locks. One possibility > would be to just cast the lock argument to (struct lock_object *) since all > of our locks have a lock_object as the first member, but then you use having > the compiler do type checking, and I'm really not willing to give up on > that. Too easy to have evil bugs that way. I suppose we could use some > evil macro that used typeof() but that would be very gcc specific? > > I guess one other possibility is to standardize on the field name for > the lock_object, calling it lo_object instead of mtx_object, rw_object, > sx_object, etc. Anyone else have any ideas? What about adding a new function like: static __inline struct lock_object * mtx_export_lc(struct mtx *m) { return (&m->mtx_object); } to be per-interface (so having sx_export_lc() and rw_export_lc() too) and than using in this way: static struct mtx foo_lock; static struct cv foo_cv; ... mtx_lock(&foo_lock); ... cv_wait(&foo_cv, mtx_export_lc(&foo_lock)); (obviously using new struct lock_object methods you added for locking/unlocking) It sounds reasonable to you? Attilio -- Peace can only be achieved by understanding - A. Einstein