LinuxQuestions.org
Register a domain and help support LQ
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-29-2006, 02:20 AM   #1
ankurcse
LQ Newbie
 
Registered: Mar 2006
Posts: 29

Rep: Reputation: 15
To get 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 ?

And as u see, i m using different key values as well.
 
Old 04-29-2006, 03:56 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
ok, you're just being stupid now...

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
 
Old 04-29-2006, 11:33 AM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
Closed... I feel deja vu anyone?
 
  


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 02:04 PM
i want to obtain two different shared memories ankurcse Linux - Kernel 2 04-28-2006 02:03 PM
want to get two different shared memories ankurcse Linux - Networking 3 04-28-2006 04:19 AM


All times are GMT -5. The time now is 09:38 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration