LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 12-28-2010, 02:48 AM   #1
devilszone
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
Posix shared memory usage


Hello techies,

I am new to LinuxQuestions.org.
I want to use Posix shared memory functions shm_open shm_unlink etc..
to create shared memory logs for some s/w module so there is less I/O.
I want to check , if i kill the process without shm_unlink() does the shared memory object floats in the memory or it is deleted automatically.

Also, which is better interface for shared memory access
POSIX / SysV?

Thanks
 
Old 12-31-2010, 11:42 AM   #2
redhatstand
Member
 
Registered: Jul 2006
Location: Oxford, UK
Distribution: CentOS, Ubuntu
Posts: 37

Rep: Reputation: 7
Hi,

Can't answer the POSIX version question, but I can for the SystemV - all the linux books I have only talk about SysV IPC (with the exception of saying that POSIX message queues are more flexible in Linux than SysV)

shmget - allocates
shmat - attaches. do this in the parent and there's no need to do it in the children
shmctl - amongst other things, call this to flag for deallocation.
shmdt - detach (NOT deallocate) happens automatically when process inheriting or attaching ends

Deallocation is explicitly required even when the allocating parent and all other attached processes die.

Deallocation happens at reboot(!), or when both of the following are true:
A process has used shmctl to flag the region for delete AND
All processes have detached, either by dying, or by calling shmdt.

I was tempted to flag for delete early, like unlinking a tmp file, but apparently this can have undesirable results platform by platform

Hope that's useful,

Andy T

Last edited by redhatstand; 12-31-2010 at 11:58 AM. Reason: finger trouble
 
Old 12-31-2010, 12:14 PM   #3
redhatstand
Member
 
Registered: Jul 2006
Location: Oxford, UK
Distribution: CentOS, Ubuntu
Posts: 37

Rep: Reputation: 7
Oh, and just noticed you posted this in hardware - it'll probably get moved to programming.

Trust me, allocating any kind of application memory in *nix you won't get closer than 8 stack pushes of allocating actual physical memory ;-)
 
  


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
Posix shared memory usage devilszone Linux - Software 1 12-28-2010 08:56 AM
distributed posix shared memory hrmb Linux - Hardware 0 01-01-2010 04:27 PM
posix shared memory regions caverdave Linux - Newbie 2 07-09-2009 09:00 AM
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 > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:51 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