I've been trying to do the same thing (mmap ANON|SHARED that is) with no
success. It only works for me if I physically create a file in the
file system. Most every UNIX seems to either mmap() ANON|SHARED or mmap()
/dev/zero in order to get a block of memory for shared access by all
children, without having to go to the file system.

I used to use shmget() but had issues with memory regions NOT going away
if the app core-dumps. The mmap() is nice because the OS cleans up in the
event of a core, but shmget() leaves these blocks lying around.

Is there any way of mmap()'ing ANON|SHARED in Linux without fs access?

Peter

On Tue, 13 Apr 1999, Brian Beuning wrote:

> Looking at the kernel (2.0.35) source code, it looks like MAP_SHARED
> requires a file descriptor.  Or put the other way, having no file descriptor
> requires MAP_PRIVATE.
> 
> If you think about it a minute, not having a file descriptor either means you
> need to have 450 MB of swap space for the memory -or- the mmap region is
> locked in memory.  Do you have more than 450 MB of physical memory?
> 
> Brian Beuning
> 
> Vincent Diepeveen wrote:
> 
> > Hello,
> >
> > I tried to add to the list, but no confirmation yet, so i
> > guess my subscription failed. Please CC me too if you answer this message.
> >
> > My problem is next:
> >
> > shmptr =
> >     mmap(0,                        /* system assigns address */
> >          450000000,                /* size of shared memory segment */
> >          (PROT_READ | PROT_WRITE), /* access rights, can be rwx */
> >          (MAP_ANON | MAP_SHARED),  /* anonymous, shared */
> >          0,                        /* file descriptor (not used) */
> >          0);                       /* file offset (not used) */
> >
> > I get error:
> > : Invalid argument.
> >
> > MAP_ANON|MAP_SHARED is not supported by that kernel 2.0.something that is
> > in redhat 5.1
> >
> > I wonder whether new kernels > 2.2.x support this
> > MMAP option, because i can allocate 2 times more memory then than i do
> > now, and don't need to swap that whole file into memory then.
> >
> > Note that the shmget function doesn't work either for me.
> >
> > This function supports maximum of 4 megabytes shared memory,
> > which is around 100 times less than i need.
> >
> > Greetings,
> > Vincent Diepeveen.
> >
> > -
> > Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/mentre/smp-faq/
> > To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]
> 
> -
> Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/mentre/smp-faq/
> To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]
> 

-
Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/mentre/smp-faq/
To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]

Reply via email to