LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Closed Thread
  Search this Thread
Old 04-27-2006, 11:45 PM   #1
ankurcse
LQ Newbie
 
Registered: Mar 2006
Posts: 29

Rep: Reputation: 15
want to get 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, 01:37 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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

this is also clearly nothing to do with networking
 
Old 04-28-2006, 02:57 AM   #3
ankurcse
LQ Newbie
 
Registered: Mar 2006
Posts: 29

Original Poster
Rep: Reputation: 15
sorry, this willn't repeat again
 
Old 04-28-2006, 03:19 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
that's a joke right? 5 minutes after saying that you do it again!
 
  


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
Some old memories and refreshments-Be BinJajer Other *NIX 2 12-31-2005 03:36 PM
partition resizing using parted...bad memories of fdisk rextor Linux - General 1 07-30-2005 10:34 AM
Is there any other memories I can use in this machine? Mega Man X Linux - Hardware 3 11-13-2004 08:10 PM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 07:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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