bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] Implement basic sleeping locks for gnumach.


From: Agustina Arzille
Subject: Re: [PATCH 1/2] Implement basic sleeping locks for gnumach.
Date: Sun, 29 Jan 2017 22:31:00 -0300

On 2017-01-29 21:34, Samuel Thibault wrote:
Agustina Arzille, on Sun 29 Jan 2017 21:11:12 -0300, wrote:
On 2017-01-29 17:44, Samuel Thibault wrote:
>Agustina Arzille, on Sun 29 Jan 2017 16:46:45 -0300, wrote:
>
>There is just one thing I'm a bit afraid of: the code is assuming that
>the only reason why the locker thread is awakened is that it was given
>the mutex control. Is that guaranteed?

Well, the locker thread checks the wait_result value: If it's
THREAD_AWAKENED,
it assumes that control of the mutex was transferred to it; otherwise, it
assumes it was interrupted. I *think* that's good enough.

But what if some other thread, completely unrelated to the mutex, wakes
the locker thread, for whatever reason unrelated to the mutex?


That case isn't covered. That said, such thread would have to do a clear_wait on the locker thread with a result of THREAD_AWAKENED, and that seems a bit
malicious to me.


The sleep queue is already protected inside assert_wait with a
simple_lock.

What you however want to serialize together is changing the mutex state
and the wakeup.


Right.

Yes, "any" here is important, I'd say, otherwise one could think that
it's only one thread we have missed, while we actually have checked for
all of them.

Good point. The next patch will be more clear :)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]