9fans archive / 2000 / 09 / 185 /    prev next

From: presotto@pla...
Subject: Re: [9fans] spin/trace source for plan9 scheduler
Date: Mon, 18 Sep 2000 17:07:43 -0400

No, we're doing that now.  Gerard is currently analysing sleep/wakeup/postnote
using the actual code.  I've taken Richard Miller's solution to sleep/wakeup
to heart and then changed it to make the explanation easier.  His solution is
probably better but I changed it to lock both the rendezvous and process
lock simultaneously in sleep, wakeup, and postnote.  It means that I have to
break the possible lock ordering deadlock in postnote (which I do by releasing
and reacquiring) but it makes explaining that p->r and r->p are consistent a
lot easier, i.e., they're both always changed under both locks.

Of course Gerard found another possible hole that we're going to define
away as not a hole.  To wit:


	p1			p2
	make cond=true
	call wakeup
	.			call sleep
	.			cond == true ?y
	.			cond = false // never mind the sleep
	.			.
	.			.
	.			call sleep
	.			cond == true ?n
	.			goto sleep
	check sleepers
	find p2
	wake him up
				wakes up
				condition == false!

The idea here is that sleep gets called twice before wakeup gets going.
The problem is that p2 is awakened when it shouldn't be.  We define it
away by saying that you aren't guaranteed after the sleep that the
condition is set, you need to check.

When gerard has finished, I'll post the current version of proc.c
and gerard's conclusions.