Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


Closed Thread
  Search this Thread
Old 04-28-2006, 03:02 AM   #1
LQ Newbie
Registered: Mar 2006
Posts: 29

Rep: Reputation: 15
i want to obtain two different shared memories

i m giving diiferent key values as the 1st argument in shmget() in two different files like, (key_t)12, (key_t)1234. But shmat() is attaching same memeroy address to different processes. Suppose i want two different shared memories for two different processes, then how it can be done. i have tried several possiblities for 1st argument of shmget(), but on doing shmat() i m getting same memory address.



int *shm_mem, shmid ;

shmid = shmget((key_t)12, sizeof(int)*10, 0666 | IPC_CREAT) ;

shm_mem = shmat(shmid, (void*)0, 0 );




int *shm_mem, shmid ;

shmid = shmget((key_t)"/test/test1.c", sizeof(int)*100, 0666 | IPC_CREAT ) ;

shm_mem = shmat(shmid, (void*)0, 0 ) ;


Now the problem is: i m getting same value of shm_mem, inspite i m using different key values in shmget().
How i can obtain two different shared memories ?
Old 04-28-2006, 09:38 AM   #2
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,786

Rep: Reputation: 1311Reputation: 1311Reputation: 1311Reputation: 1311Reputation: 1311Reputation: 1311Reputation: 1311Reputation: 1311Reputation: 1311Reputation: 1311
Use a different key.
Old 04-28-2006, 01:03 PM   #3
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
want to get two different shared memories ankurcse Linux - Software 1 04-28-2006 01:04 PM
want to get two different shared memories ankurcse Linux - Networking 3 04-28-2006 03:19 AM
Some old memories and refreshments-Be BinJajer Other *NIX 2 12-31-2005 03:36 PM

All times are GMT -5. The time now is 07:48 PM.

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