The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shared memory in shared library DreamWarrior High Level Programming 12 05-30-2007 04:33 PM
memory sharing - not shared memory - elzalem High Level Programming 9 05-02-2007 07:45 AM
help with shared memory ddx08 High Level Programming 6 04-06-2007 09:53 AM
Shared memory shortage but lots of unused memory cjcamaro UNIX for Advanced & Expert Users 1 10-13-2004 05:10 PM
Shared Memory Jayathirtha UNIX for Advanced & Expert Users 3 03-03-2003 12:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-24-2001
joseph_shibu joseph_shibu is offline
Registered User
  
 

Join Date: Oct 2001
Location: India
Posts: 7
Shared memory

Dear Reader,

Is is necessary to attach / dettach the shared memory segments for write operations , if more than one program is accessing same shared memory segments..
I have used semaphore mutex and still I'm getting segmentation fault when I write to the segment when other program is already attached to it... Is something else wrong..

Thanks,
  #2 (permalink)  
Old 10-24-2001
Neo's Avatar
Neo Neo is online now Forum Staff  
Administrator
  
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 6,658
Only one process (at a time) may have an open file descriptor for a shared memory segment. The interprocess communication that is used to insure proper file access is the semaphore.

When a semaphore is used correctly (and it can be tricky!) the problem with shared memory segmentation error will be solved (more than likely, unless you have a pointer or other C programming error).

Here is a basic algorithm:
[list=1][*]Create a shared memory segment.[*]Create a semaphore.[*]Process A acquires the semaphore used for the shared memory segment.[*]Process A opens the shared memory.[*]Process A does cool things with shared memory.[*]Process A closed the shared memory segment.[*]Process A releases the semaphore.[*]Process B has been waiting for the semaphore to be released.[*]Now that semaphore has been released......[*]Process B acquires the semaphore used for the shared memory segment.[*]Process B opens the shared memory.[*]Process B does cool things with shared memory.[*]Process B closed the shared memory segment.[*]Process B releases the semaphore.[/list=1]

Yadda, yadda, yadda....... does this help?
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0