Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    is the Semaphore a mutex? [SOLVED]

    SDK Help
    0
    6
    472
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post