Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Nov 2000 11:51:06 -0500 (EST)
From:      Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To:        Mike Smith <msmith@FreeBSD.org>
Cc:        cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/sys eventhandler.h 
Message-ID:  <200011151651.LAA73071@khavrinen.lcs.mit.edu>
In-Reply-To: <200011150701.eAF71iF01864@mass.osd.bsdi.com>
References:  <200011150403.XAA67532@khavrinen.lcs.mit.edu> <200011150701.eAF71iF01864@mass.osd.bsdi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Tue, 14 Nov 2000 23:01:44 -0800, Mike Smith <msmith@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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011151651.LAA73071>