LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-30-2012, 04:31 AM   #1
Vinay L
LQ Newbie
 
Registered: Jun 2012
Posts: 6

Rep: Reputation: Disabled
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
 
Old 07-30-2012, 05:08 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,871
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
What do you mean by 'shared memory file'? Shared memory is in memory, not file...
 
Old 07-30-2012, 05:13 AM   #3
gchen
Member
 
Registered: May 2012
Location: Beijing China
Distribution: Asianux
Posts: 56

Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by Vinay L View Post
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.


: )
 
Old 07-30-2012, 05:18 AM   #4
gchen
Member
 
Registered: May 2012
Location: Beijing China
Distribution: Asianux
Posts: 56

Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by NevemTeve View Post
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.

: )
 
Old 07-30-2012, 05:59 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,871
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Checked my /dev/shm/ directory, it is full empty (Debian/linux 6.0.5; uname -r = 3.3.7; ipcs -m | wc -l = 21)
 
Old 07-30-2012, 06:09 AM   #6
Vinay L
LQ Newbie
 
Registered: Jun 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
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
 
Old 07-30-2012, 09:24 AM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Vinay L View Post
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.
 
Old 07-30-2012, 09:36 PM   #8
gchen
Member
 
Registered: May 2012
Location: Beijing China
Distribution: Asianux
Posts: 56

Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by theNbomr View Post
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.

: )
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Location of POSIX semaphores on Mac OS Vinay L Other *NIX 2 07-14-2012 02:07 AM
Posix shared memory usage devilszone Linux - Hardware 2 12-31-2010 12:14 PM
distributed posix shared memory hrmb Linux - Hardware 0 01-01-2010 04:27 PM
POSIX Shared Memory noiz354 Linux - Hardware 1 02-27-2009 01:10 PM
POSIX shared memory confusion MeMooMeM Programming 0 05-25-2005 04:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration