Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 0
shmat() with fixed address


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);

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, 08:02 PM   #2
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


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

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