semaphore memory allocation
-
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?
-
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?
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. -
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.superman does this reply my question?
-
superman does this reply my question?
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. -
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.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?
-
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?
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
orReleaseSemaphore
respectively.«_Superman_»
I love work. It gives me something to do between weekends.