[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Mac OS X Build
From: |
John Gilmore |
Subject: |
Re: [Discuss-gnuradio] Mac OS X Build |
Date: |
Fri, 28 Nov 2003 16:04:32 -0800 |
> my shared memory problem in VrBuffer.cc. I still have to sit down and
> translate the System V shared memory routines to BSD style.
The basic problem is to map a section of RAM into virtual memory
twice, contiguously. I can think of two ways to do it:
* Allocate the memory and map it to a file. Then map the file
to the second address range too. (You can unlink the file then,
I think, so that it will disappear after the process terminates.)
* Allocate the memory anonymously (e.g. from /dev/zero). Then map
the second address range from the process's own address space
(e.g. using file "/proc/MYPID/mem" or "/proc/self/mem" if BSD
supports this).
Mmap is more flexible than shmat; you can map particular byte ranges
to particular sets of pages. This should simplify the code.
The current code maps a 2N sized buffer, solely to determine where in its
address space there's room for a 2N sized, page-aligned, buffer. It then
detaches that buffer and deletes it.
The mmap-based code can map a 2N sized buffer immediately, and then
just unmap the second half of it, and remap that second half from the
first half.
John