Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Linux shared memory question

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Prune   Members   

223
Like
0Likes
Like

Posted 06 February 2012 - 12:20 AM

Regarding shm_unlink(), I see the following description:
"the removal of the memory object contents shall be postponed until all open and map references to the shared memory object have been removed."

Does this mean I can call close() and shm_unlink() immediately after mmap() and then know that the shared memory will still be there until I call munmap()? This way, in a RAII object I'd not need to store the fd and/or name in members for the dtor, and I'd only need the pointer?

That is, is this valid:
ctor: shm_open(), ftruncate(), mmap(), close(), shm_unlink()
dtor: munmap()

Thanks
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)

#2 Prune   Members   

223
Like
1Likes
Like

Posted 07 February 2012 - 11:46 AM

Managed to answer my own question. Can't close both the name and the fd as the other process needs one or the other in order to open the shmem.
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.