0

i have studied that for process to communicate with each other they need to keep their critical region in shared memory,so that other process which needs access to that can use it,using different variables for mutual exclusion,like semaphore and lock.

but where is this shared memory located,is that the same shared memory /dev/shm that we see when we do df -h.Sometimes /dev/shm is using some space sometimes not.why is it so.

Kevin Parker
  • 757
  • 1
  • 13
  • 32

1 Answers1

3

You can create shared memory several ways. You can memory map the same file shared in both processes. Or you can uses sysv shared memory with shm_open.

David Schwartz
  • 31,449
  • 2
  • 55
  • 84
  • so does /dev/shm that we see also serves the same purpose.So why clearing the contents in /dev/shm does not make any difference? – Kevin Parker Aug 15 '12 at 10:55
  • 1
    `/dev/shm` is just one mechanism of creating shared memory. It's basically memory mapping the same file in both processes, except the file is backed only by memory. – David Schwartz Aug 15 '12 at 11:03