LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


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

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


Hi,
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.


ex:
first.c

main()
{

int *shm_mem, shmid ;

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

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

}

second.c

main()
{

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
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

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

Rep: Reputation: 67
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.

http://www.linuxquestions.org/rules.php
 
  


Closed 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 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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:00 PM.

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