serializing token

joe pistritto joepistritto at yahoo.com
Fri Apr 23 22:26:31 PDT 2004


I am looking at the serializing token work some more
and I have a few questions. I hope it is not a bother
for y'all to answer.

As I understand it, multiple threads can hold tokens
but only one of the threads holding a particular token
can be running at any time. As I looked at the lwkt
token implementation, I believe obtaining a token
reference is a blocking point, is this correct? What I
mean is if thread A is running and holding token T,
and thread B attempts to grab a reference to token T,
thread B blocks (and the scheduler gets invoked to run
another thread) since A is already running. Is this
correct?

If a call to get a token reference is a blocking
point, then what happens when you need to hold more
than one token? Specifically, I am concerned with this
case: Token T1 protects list L1 and token T2 protects
list L2. If the code looks like this:

lwkt_gettoken(T1);
foo = L1->head;
. ..
. ..
lwkt_gettoken(T2);
bar = L2->head;
. ..
. ..
dosomething(foo);

Is this valid/correct code? Is foo still valid after
the second lwkt_gettoken call? I ask this because the
second call to lwkt_gettoken(T2) can be a blocking
point, so some other thread can get scheduled at that
point. If another thread that is holding T1 runs, then
it could change L1 (assuming foo isn't declared
volatile, of course).

If my understanding is correct, then is the code for
sysctl_vnode() in src/sys/kern/vfs_subr.c incorrect?
In this function (which I see is #if 0'd out), it
takes the token for mountlist_token, which I presume
protects the mountlist. Then it takes the token for
mnbtvnode_token. However, the head of the mountlist,
obtained before it takes the second token, is used
after the second token acquisition. So, this code is
wrong since the head of the mountlist could have
changed, right???

Apologies in advance if this seems like a stupid
question.

-J

--- joe pistritto <joepistritto at xxxxxxxxx> wrote:
> Hi,
> 
> I just found out about Dragonfly BSD and read the
> web
> page. This seems like a really cool project. I would
> like to learn more about the serializing token and
> how
> that works. Are the papers that describe the
> programming model using serializing token?
> 
> Thank you,
> 
> -J



 



	
		
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
http://photos.yahoo.com/ph/print_splash





More information about the Kernel mailing list