diff --git a/l10/l10-handout.txt b/l10/l10-handout.txt index 4502406..54421b1 100644 --- a/l10/l10-handout.txt +++ b/l10/l10-handout.txt @@ -108,7 +108,8 @@ Class 10 Moral of the above paragraph: if you're implementing a concurrency primitive, read the processor's documentation about - how loads and stores get sequenced. + how loads and stores get sequenced (chapter 8 in current + architecture manual). The spinlock above is great for some things, not so great for others. The main problem is that it *busy waits*: it spins, @@ -302,7 +303,7 @@ Class 10 buffer [in] = nextProduced; in = (in + 1) % BUFFER_SIZE; count++; - cond_signal(&nonempty); + cond_signal(&nonempty, &mutex); release(&mutex); } } @@ -317,7 +318,7 @@ Class 10 nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; count--; - cond_signal(&nonfull); + cond_signal(&nonfull, &mutex); release(&mutex); /* next line abstractly consumes the item */ @@ -451,6 +452,7 @@ Class 10 --count; cond_signal(&nonfull, &mutex); mutex.release(); + return ret; } int main(int, char**)