is the Semaphore a mutex? [SOLVED]
-
On 07/11/2014 at 11:22, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) :---------
The documentation does not mention anything specific. From my tests, it looks like the Cinema 4D
Semaphore class provides mutual exclusion, which would conflict with the general understanding of
a semaphore being just a resource counter.Thanks
Niklas -
On 07/11/2014 at 12:25, xxxxxxxx wrote:
Hi NiklasR,
When I compare the implementation, which matches the SDK docs description, of the Semaphore class, I can confirm without a doubt that it's a binary semaphore (mutual exclusion), not a counting semaphore (resource availability counter), as explained on Wikipedia:
http://en.wikipedia.org/wiki/Semaphore\_(programming)
I understand the confusion. I guess, like me, you learned in school the term 'mutex' for what is described here as 'binary semaphore', and learned 'semaphore' for 'counting semaphore'.Joey Gaspe
SDK Support Engineer -
On 08/11/2014 at 05:01, xxxxxxxx wrote:
Thank you for the clarification, Joey. Yes, that is indeed what I learned. Except that a mutex can only be,
for my understanding, release by the thread it acquired while a binary semaphore can be released from
any thread. From my tests, it seems like the C4D Semaphore is a reentrant mutex.Best
Niklas -
On 08/11/2014 at 09:56, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Thank you for the clarification, Joey. Yes, that is indeed what I learned. Except that a mutex can only be, for my understanding, release by the thread it acquired while a binary semaphore can be released from any thread. From my tests, it seems like the C4D Semaphore is a reentrant mutex.
Yes it is what we call these days a reentrant (aka recursive) - mutex. If you look back in time when this was created ('round the millennium) there used to be alternate terms for this - e.g. FreeRTOS (which was created around that time too) also calls the reentrant mutex a "<xSemaphore> which represents a mutex semaphore".
Best regards,
Wilfried
-
On 10/11/2014 at 07:03, xxxxxxxx wrote:
Hi,
I'm thinking the documentation should be updated to explain that it's a reentrant mutex, so I'll look into having that done. Otherwise, case closed!
Thanks for the added info guys.
Joey Gaspe
SDK Support Engineer -
On 10/11/2014 at 07:14, xxxxxxxx wrote:
Thanks for the answer, Wilfried and Joey. I agree that a small note in the documentation would be fine.
Just because it's an old implementation does not require the documentation to be outdated/cumbersome.Niklas