I forgot to mention that the algorithm was stolen from the paper "Futex
Are Tricky", by Ulrich Drepper. You can see an explanation there. But
with the comments I added I think it is easier to see what is going on.
Juho Snellman wrote:
> Marco Monteiro <masm@...> writes:
>> As currently implemented, release-mutex makes a system call even if
>> there is no contention for the mutex. This patch corrects that.
>> In my system, with an uncontended mutex, RELEASE-MUTEX is more than
>> 30x faster with the patch.
>> I tested the patch in a x86-64 machine running Linux. I created VOPs
>> for x86 but I did not test this.
>> Please review and apply.
> Thanks. A few issues:
> * It's not immediately obvious that the code is correct. Could you add
> some comments that explain what is going on, and why it's correct?
> * The mutex structure now has fields named VAL and VALUE, which isn't
> very clear. VAL should probably be renamed to something more descriptive.
> Maybe STATE?
> * There are lots of magic numbers in the code. They should probably
> be named.
>> The new VOPs will be reworked in a future patch.
> In what way?