[squeak-dev] Mutex test question

Jaromir Matas mail at jaromir.net
Sat May 28 18:46:37 UTC 2022


Hi,
I wonder what the correct behavior should be when terminating a process waiting to get access to a Mutex’s #critical section…

testMutexBlockedInCritical          "self run: #testMutexBlockedInCritical"

                | lock sock proc wait |
                lock := Mutex new.
                sock := Semaphore new.
                proc := [lock critical: [sock wait]] fork.
                wait := [[] ensure: [lock critical: []]] fork.  "<---- important"
                Processor yield.
                self assert: proc suspendingList == sock.
                self assert: wait suspendingList == lock.
                self deny: lock isEmpty.
                self assert: lock isOwned.
                wait terminate.
                Processor yield.
                self assert: wait isTerminated.
                self assert: proc suspendingList == sock.
                self assert: wait suspendingList == nil.
                self assert: lock isEmpty.
                self deny: lock isOwned            "<---- is this right???"

I expected the Mutex ownership would remain unchanged but to my surprise the terminating process niled the ownership and so as a result you have a previous owner still waiting inside the Mutex but without the ownership…

This is not a new behavior, it’s already in 5.3

Is this a bug or my misunderstanding?
Thanks a lot,
best
Jaromir

--

Jaromír Matas

mail at jaromir.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220528/7cbe7bd3/attachment.html>


More information about the Squeak-dev mailing list