Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. semaphore memory allocation

semaphore memory allocation

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
6 Posts 2 Posters 0 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rupeshkp728
    wrote on last edited by
    #1

    If say a process creates a semaphore/mutex etc then will this semaphore get created in its address space? If yes then how an another process which wants to acquire this semaphore(created by the first process) will access the first process address space to acquire the semaphore? Anybody can pls explain me this?

    _ 1 Reply Last reply
    0
    • R rupeshkp728

      If say a process creates a semaphore/mutex etc then will this semaphore get created in its address space? If yes then how an another process which wants to acquire this semaphore(created by the first process) will access the first process address space to acquire the semaphore? Anybody can pls explain me this?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Semaphores, Mutexes etc. are kernel objects and memory is allocated in the kernel address space. The processes that access these kernel objects which open handles to the objects. The kernel object will be deallocated when the last handle referencing the object is closed.

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      R 1 Reply Last reply
      0
      • _ _Superman_

        Semaphores, Mutexes etc. are kernel objects and memory is allocated in the kernel address space. The processes that access these kernel objects which open handles to the objects. The kernel object will be deallocated when the last handle referencing the object is closed.

        «_Superman_»
        I love work. It gives me something to do between weekends.

        Microsoft MVP (Visual C++)

        Polymorphism in C

        R Offline
        R Offline
        rupeshkp728
        wrote on last edited by
        #3

        superman does this reply my question?

        _ 1 Reply Last reply
        0
        • R rupeshkp728

          superman does this reply my question?

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Each process has its own handle table. When you create a new mutex, memory is allocated elsewhere, but a handle is held within each process that references this mutex.

          «_Superman_»
          I love work. It gives me something to do between weekends.

          Microsoft MVP (Visual C++)

          Polymorphism in C

          R 1 Reply Last reply
          0
          • _ _Superman_

            Each process has its own handle table. When you create a new mutex, memory is allocated elsewhere, but a handle is held within each process that references this mutex.

            «_Superman_»
            I love work. It gives me something to do between weekends.

            Microsoft MVP (Visual C++)

            Polymorphism in C

            R Offline
            R Offline
            rupeshkp728
            wrote on last edited by
            #5

            Thanks Superman for the inputs. Ok so this means that the mutex/semaphore will not be allocated in the process address space but in some other shared address space where it will be shared by multiple process/threads. Am I correct? So when an another thread/process tries to access a shared resource then it will see that the particular resource is protected by a certain mutex/semaphore and then it will try to get the handle to the mutex/semaphore using some mechanism. Is my thinking ok?

            _ 1 Reply Last reply
            0
            • R rupeshkp728

              Thanks Superman for the inputs. Ok so this means that the mutex/semaphore will not be allocated in the process address space but in some other shared address space where it will be shared by multiple process/threads. Am I correct? So when an another thread/process tries to access a shared resource then it will see that the particular resource is protected by a certain mutex/semaphore and then it will try to get the handle to the mutex/semaphore using some mechanism. Is my thinking ok?

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              Process/Thread synchronization has to be handled by the programmer. What I mean is that, for any shared resource intended to be protected by a mutex or semaphore, the wait functions[^] must be used on the handles of these objects so that these resources remain synchronized. The wait functions will block access till a mutex or semaphore is release using ReleaseMutex or ReleaseSemaphore respectively.

              «_Superman_»
              I love work. It gives me something to do between weekends.

              Microsoft MVP (Visual C++)

              Polymorphism in C

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups