9fans archive / 2000 / 08 / 78 /    prev next

From: presotto@pla...
Subject: Re: [9fans] Kernel question: i386 test-and-set problem
Date: Wed, 2 Aug 2000 12:24:41 -0400

As I said in the last message, there has to be synchronization
external to the sleep code to make such a situation work.  For
example

	lock list
	add to list
	unlock list
	sleep
	lock list
	free
	unlock list

and another process will do

	lock list
	if(something to wakeup)
		wakeup
	unlock list

Things calling sleep/wakeup can and do perform such
synchronization.  It's part of writing a multithreaded
kernel, i.e., snchronizing accesses to structures.
You don't haphazardly free things when there are
possible accesses to them outstanding in other threads,
or at least I try not to.

Unfortunately, postnote is an asyncronous event often
initiated by someone that's trying to stop something.
It doesn't know about this external synchronization.