Re: mmap() function call...



Let's start from scratch... This may be a bit inaccurate, but anyway:

A process has a virtual address space (virtual memory).

Unless the process is swapped out, some or all of that virtual memory
is mapped to physical memory.

The virtual memory is also mapped to the swap file so that the process'
memory can be swapped/paged out if the system needs more memory. So if
you update some memory, the change will be carried through to the swap
file as well. If you read some allocated virtual memory which is not
mapped to physical memory, the corresponding data is read from the swap
file and into a new physical memory page, and the virtual memory page is
mapped do that.

mmap() with a file maps another file than the swap file to some virtual
memory. Depending on the mmap() flags, if you then update that memory,
the file is updated. If you read from that virtual memory, a chunk of
the file is if necessary read into physical memory and mapped to the
appropriate virtual memory page.

if i have a file of 100 Mb and RAM of 64 MB, will mmap() work?

If your _virtual_ address space is larger than 100M (+ whatever the
process is already using), that's no problem. If a process is using
200M virtual memory but you only have 64M phyiscal memory, then only
some of the virtual memory pages are mapped to physical memory at any
given time. The rest has been saved to the swap file or your mmapped
file. If the process tries to access an address which is not in memory
but is on file, the OS reads that address' page into a free physical
memory page from the swap/mmap file - likel after throwing some other
page out from physical memory to a file.

--
Hallvard
.



Relevant Pages

  • Re: mmap() function call...
    ... mmapwith a file maps another file than the swap file to some virtual ... Depending on the mmap() flags, if you then update that memory, ... invokes mmapwith fd1 and the exe is sample.exe. ...
    (comp.unix.programmer)
  • relic Have you learned how to post yet?
    ... As you have a selective memory, here is the source code for you. ... applications with a 4 GB virtual address space. ... that run on computers with more than 2 GB of physical memory. ... Address Windowing Extensions (AWE) enables applications to address more = ...
    (alt.os.windows-xp)
  • Re: HeapCreate() : not enough storage is available
    ... i am writing a driver creating several heaps during boot time. ... Is There any swap file with WinCE for freeing some physical memory ... there is no support for swap file on Windows CE. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Design question for memory access by processes
    ... >> particular page of the reference file is accessed. ... > assuming that the underlying mmap implementation will read each block ... > exactly once even if there is sufficient memory in the system to hold ... occur if physical memory is insufficient in the whole system ...
    (comp.unix.programmer)
  • Re: RAM
    ... For applications that are I/O-intensive, ... The 4GT RAM Tuning feature increases the memory ... more than 2 GB of physical memory. ... VirtualAlloc function. ...
    (alt.os.windows-xp)