LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Location of POSIX shared memory on Mac OS (https://www.linuxquestions.org/questions/programming-9/location-of-posix-shared-memory-on-mac-os-4175419322/)

Vinay L 07-30-2012 04:31 AM

Location of POSIX shared memory on Mac OS
 
Hi All,

I am using shared memory in my application. On linux POSIX shared memory file is created at /dev/shm, but on Mac OS i am not able to find the /dev/shm. So I have few queries regarding the location of POSIX shared memory on Mac OS:

1. Is POSIX shared memory on Mac OS is stored as file(Just like at /dev/shm on Linux)?If Yes, Which location?
2. How POSIX shared memory implementation on Mac OS is different from Linux?

Thanks & Regards,
Vinay

NevemTeve 07-30-2012 05:08 AM

What do you mean by 'shared memory file'? Shared memory is in memory, not file...

gchen 07-30-2012 05:13 AM

Quote:

Originally Posted by Vinay L (Post 4741143)
Hi All,

I am using shared memory in my application. On linux POSIX shared memory file is created at /dev/shm, but on Mac OS i am not able to find the /dev/shm. So I have few queries regarding the location of POSIX shared memory on Mac OS:

1. Is POSIX shared memory on Mac OS is stored as file(Just like at /dev/shm on Linux)?If Yes, Which location?
2. How POSIX shared memory implementation on Mac OS is different from Linux?

Thanks & Regards,
Vinay

1), I can not reply your questions directly (for I truly not well know about that)

2), but I have some expirience of shm under Mac OS, maybe helpful for you.

3), I offten use filemapping under Mac OS instead of shm, it is work stable, and simpler than shm under Mac OS.


: )

gchen 07-30-2012 05:18 AM

Quote:

Originally Posted by NevemTeve (Post 4741162)
What do you mean by 'shared memory file'? Shared memory is in memory, not file...

for Linux specific, /dev/shm/* is for shared memory files.

most UNIXs not need do like that (such as freebsd which is the kernel for original Mac OS).

but for shm under Mac OS, truly need solving some issues which not occurs under Linux, they are truly difference. so I often use filemapping instead of.

: )

NevemTeve 07-30-2012 05:59 AM

Checked my /dev/shm/ directory, it is full empty (Debian/linux 6.0.5; uname -r = 3.3.7; ipcs -m | wc -l = 21)

Vinay L 07-30-2012 06:09 AM

Thanks for your reply.

@gchen: Yes. In FreeBSD also /dev/shm doesn't exist. Can you plz provide me some details about where it is stored in FreeBSD or If it is not stored as the file, then how it handled(Is it stored in some shared memory space may be maintained by kernel where users cannot access)?


@NevemTeve: In Linux, each POSIX Shared memory or Semaphore created is stored as file under /dev/shm directory.



Regards,
Vinay

theNbomr 07-30-2012 09:24 AM

Quote:

Originally Posted by Vinay L (Post 4741201)
In Linux, each POSIX Shared memory or Semaphore created is stored as file under /dev/shm directory.

What you say is, AFAIK, true. However please note that /dev/shm is not an actual data store on a disk, but is a virtual filesystem. While it can be accessed using the usual filesystem semantics, its underlying data is produced at runtime by the Liniux kernel.
Don't know whether this contributes to your question, but it seemed worth pointing out.

--- rod.

gchen 07-30-2012 09:36 PM

Quote:

Originally Posted by theNbomr (Post 4741349)
However please note that /dev/shm is not an actual data store on a disk, but is a virtual filesystem. While it can be accessed using the usual filesystem semantics, its underlying data is produced at runtime by the Liniux kernel.

1st, support what said above.

2nd, For the named object(such as shm), it has an ID (or a string under Windows OS) which defined by user, and should be knowned by the processes which will use it. And another none-relative processes need not know it.

3nd, many UNIXs implenment "/dev/shm/*", it is only for making monitoring or administration easier. It (/dev/shm/*) is not required by the processes which will use shm.

: )


All times are GMT -5. The time now is 11:08 PM.