From owner-freebsd-current Mon Jul 8 17:47: 2 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 971B537B400 for ; Mon, 8 Jul 2002 17:46:57 -0700 (PDT) Received: from mail.speakeasy.net (mail13.speakeasy.net [216.254.0.213]) by mx1.FreeBSD.org (Postfix) with ESMTP id 062E943E09 for ; Mon, 8 Jul 2002 17:46:57 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 17291 invoked from network); 9 Jul 2002 00:46:54 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail13.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 9 Jul 2002 00:46:54 -0000 Received: from laptop.baldwin.cx (laptop.baldwin.cx [192.168.0.4]) by server.baldwin.cx (8.11.6/8.11.6) with ESMTP id g690kgf06514; Mon, 8 Jul 2002 20:46:42 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20020708235244.76569.qmail@web20902.mail.yahoo.com> Date: Mon, 08 Jul 2002 20:46:53 -0400 (EDT) From: John Baldwin To: David Xu Subject: Re: Timeout and SMP race Cc: Julian Elischer Cc: Julian Elischer , "freebsd-current@FreeBSD.org" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 08-Jul-2002 David Xu wrote: > I want to set an flag bit CALLOUT_PROCESSING in callout.c_flags, > before softclock() releases callout_lock and start requesting > callout.c_func(), so callout_stop can find that callout is processing > by softclock and wait, after softclock processed the callout, it > resets the flag and wakeup callout_stop thread, of course, if > callout_stop is being called in softclock() thread, it should avoid > waiting, it is easy to detect. This doesn't work. The callout function can do a callout_reset() on itself to reschedule itself. Well, if all the various callout functions check for the processing flag it might work. Then you have to figure out how to properly wait. You can't use a cv as they don't work with spin mutexes. Hmmm, this is one of the times I wish we could wait on a cv with a spin mutex. You could do something evil where you had a cv and a mutex, unlocked callout lock, locked mutex, locked callout lock, rechecked condition, then blocked if needed. Similar evilness required when doing a wakeup as well. We can cheat in the endtsleep() case because we know what thread to wakeup as well. We don't easily have that in the general case unless we bloat struct callout a bit. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message