public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bud Davis <bdavis9659@sbcglobal.net>
To: Vishnu M Menon <vishnu_m_menon@yahoo.com>, gcc-help@gcc.gnu.org
Subject: Re: Reserving the same virtual address space range in several programs
Date: Sun, 11 Mar 2007 17:37:00 -0000	[thread overview]
Message-ID: <37955.19203.qm@web81213.mail.mud.yahoo.com> (raw)
In-Reply-To: <803480.85995.qm@web38906.mail.mud.yahoo.com>


--- Vishnu M Menon <vishnu_m_menon@yahoo.com> wrote:

> Hi,
> 
> I am trying to solve this problem: reserve the same
> virtual memory address range in a given set of
> programs so that no addresses falling within this
> range will be used by the processes for any other
> purpose. Later I'll map a shared memory region to
> this
> address using mmap(.) or shmat(.).
> 
> My question is: is there a way I can use GCC to
> achieve this VM address reservation? The programs
> are
> fully in my control and are extremely specialized,
> so
> I am at liberty to use techniques sane people would
> balk at.
> 
> To give a clearer idea of what I'm getting at,
> reserving 10 MB of memory space might be achieved
> through something like:
> 
> char g_MemArray[ 10 * ( 1 << 20 ) ];
> 
> int
> main()
> {
>     printf("Starts at %p\n", g_MemArray );
>     return 0;
> }
> 
> But of course, layout of global variables will vary
> from program to program. I am trying to see if
> somehow
> the layout can be specified so that VM addresses are
> guaranteed to be the same.
> 
> TIA for the replies. I would also welcome any
> solutions that do not involve gcc, though I realize
> this would be off-topic (for which I apologize in
> advance!). 
> 
> Regards,
> Vishnu
> 


there is an example on the web showing how to do this
on a unix system (it concerns fortran common blocks,
but the concepts are the same).

http://gfortran.info/pmwiki.php?n=CodeSnippets



      reply	other threads:[~2007-03-11 16:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-11 14:46 Vishnu M Menon
2007-03-11 17:37 ` Bud Davis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37955.19203.qm@web81213.mail.mud.yahoo.com \
    --to=bdavis9659@sbcglobal.net \
    --cc=gcc-help@gcc.gnu.org \
    --cc=vishnu_m_menon@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).