LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-04-2010, 07:59 PM   #1
poojithas
LQ Newbie
 
Registered: Jun 2010
Location: Chennai, India
Distribution: Ubuntu 10.04
Posts: 22

Rep: Reputation: 0
shmat() with fixed address


Hi,

I'm using Ubuntu 10.04 on a 64bit machine.

In my shmat() call, I want to assign fixed memory address to shmaddr variable. I have no idea which address value to give. Some where in the net I read we can make use of sysproc info to know the user space addresses, but could not figure out how to get that, please help on this.

void *shmat(int shmid, const void *shmaddr, int shmflg);

Note:
-----
the reason I want to use fixed address is to build linked list on the shmget() returned memory and my other process will map into fixed address and access the linked list.
 
Old 12-15-2010, 07:02 PM   #2
stevexyz
LQ Newbie
 
Registered: Apr 2008
Location: Hampshire, UK
Distribution: None
Posts: 27

Rep: Reputation: 16
Hi there,

You likely do not need to know where the memory is going to be mapped:

1. Use ftok() to construct a key for the shared memory .
2a. In one process use shmget() with IPC_CREATE to create a sufficiently large shared memory segment.
2b. In your other processes use shmget() without IPC_CREATE.
3. In all the processes you then call shmat() with the id from shmget() and a NULL shmaddr. In each process shmat() returns where the memory has been mapped, that's the start of the shared segment.

Cheers, Steve
 
  


Reply


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
Using shmat to map a shared segment to a fixed location drachs Linux - Kernel 3 11-02-2010 09:20 PM
Dynamic IP address with PTR record versus Fixed IP address without ruyterb Linux - Networking 1 05-07-2010 11:43 AM
Does user stack have a fixed address location in its virtual address? lqu Linux - Kernel 1 09-11-2009 01:28 PM
i need fixed IP address. bruse Linux - Networking 5 09-19-2005 06:27 AM
Fixed IP Address with DHCP dgreenbean Linux - Networking 9 09-19-2004 01:12 PM


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