From owner-cvs-all Wed Nov 15 8:51:13 2000 Delivered-To: cvs-all@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 68D9837B4D7; Wed, 15 Nov 2000 08:51:08 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id LAA73071; Wed, 15 Nov 2000 11:51:06 -0500 (EST) (envelope-from wollman) Date: Wed, 15 Nov 2000 11:51:06 -0500 (EST) From: Garrett Wollman Message-Id: <200011151651.LAA73071@khavrinen.lcs.mit.edu> To: Mike Smith Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys eventhandler.h In-Reply-To: <200011150701.eAF71iF01864@mass.osd.bsdi.com> References: <200011150403.XAA67532@khavrinen.lcs.mit.edu> <200011150701.eAF71iF01864@mass.osd.bsdi.com> Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG < said: > It's not so much the blocking that's an issue as that the list is dynamic > and may change while you're in flight over it. The non-blocking is just a side benefit of using two queues. The way it works is simply: You have two queues, call them ``wait'' and ``done''. Everything starts out on ``wait''. When you need to do a traversal, you remove an item from the head of ``wait'', perform the action, and add the item to the tail of ``done''. When ``wait'' is empty, swap ``wait'' and ``done''. Because you're always operating on either the head or the tail of a queue, you don't need to worry about having to re-validate your iterator after a sleep. Deletes just set a flag and wait for the next traversal; inserts always happen at the tail of ``wait''. This obviously doesn't work if you allow recursive entry to the traversal routine. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message