Skip to main content
10 events
when toggle format what by license comment
Nov 9, 2020 at 18:44 comment added Tim I meant softwareengineering.stackexchange.com/questions/418800/…
Nov 9, 2020 at 18:42 comment added JacquesB @Tim: This is answered in the second quote in the question.
Nov 9, 2020 at 18:26 comment added Tim I meant: what differences are between a binary semaphore and a mutex lock, to a user?
Nov 9, 2020 at 18:06 comment added Useless Depends on contention patterns and whether the user would like their cores and electricity to be doing something more productive than waiting for each other. It's a question in its own right, but try some research some before posting it.
Nov 9, 2020 at 18:06 comment added JacquesB @Tim: A spin lock takes up processor resources when spinning, a block does not since the thread is suspended by the OS. But blocking requires a system call, so it has some overhead. This is why an implementation may combine them. If a lock is only locked for at short while, it is more efficient to spin wait. But if it is locked for longer than the system call overhed, it is better to block.
Nov 9, 2020 at 17:56 comment added Tim @JacquesB Both a binary semaphore and a mutex lock can be implemented as spin waiting, blocking or both. What differences are between them, to a user?
Nov 9, 2020 at 17:42 comment added JacquesB @Tim: A semaphore can also be spin waiting or blocking or both, just like a mutex.
Nov 9, 2020 at 17:22 comment added Robert Harvey @Tim: I suggest you study some of these mechanisms; there is source code available on the Internet for various mutex implementations. As it is, we're mostly talking about word definitions here, which won't get you very far. Once you understand the actual mechanisms, the meaning of the word definitions should become readily apparent.
Nov 9, 2020 at 17:20 comment added Tim Thanks. If a mutex lock can be implemented as block waiting, is a mutex lock implemented as such the same as a binary semaphore? (Stalling's OS book says a mutex lock and a binary semaphore differ in whether the process that locks the mutex (sets the value to zero) must be the one to unlock it. It doesn't mention whether they differ in spinning waiting only. See the quote.)
Nov 9, 2020 at 17:12 history answered JacquesB CC BY-SA 4.0