0

I am reading the source code of mmap(), and I found the Linux kernel will make the files map into the vma struct. vma only represents memory areas. So, will the OS immediately allocate physical memory for the process after mmap()?

1 Answer 1

2

No, Linux may defer allocation of the physical memory, requested by mmap, until that memory will be accessed.

When application accesses an unmapped memory, page fault exception is triggered; when handle this exception, Linux may map that accessed memory, allowing the application to continue.

Sign up to request clarification or add additional context in comments.

2 Comments

the “unmapped memory” mentioned above should be area allocated in vma but not mapped in page table. :-)
Yes, being listed in vma gives a chance for unmapped memory to be mapped on page fault. But that page fault is caused by access to any unmapped memory, being it in vma or not. This is what my post talsk about.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.