-1

How the OS is able to do this

With virtual memory, programs running on the system can allocate far more memory than is physically available;

Dpk
  • 311
  • 5
  • 16

1 Answers1

1

It is in practice "a little more memory", not "far more memory", otherwise you are experimenting thrashing.

Every desktop, latop or server processor has an MMU. It is used by the virtual memory system to give a virtual address space thru paging & the page cache. When the kernel gets a page fault, it could fetch a page from disk -e.g. in a segment of an ELF executable or shared object or some other mapped file, or some pages from the swap area- or send a SIGSEGV signal, see signal(7).

On Linux, several system calls can change the address space: mmap(2) and munmap (and also the obsolete sbrk, etc...) and execve(2). You might advise the kernel using madvise(2)

You could use cat /proc/$somepid/maps (e.g. cat /proc/$$/maps in your shell) to understand the address space map of some process. See proc(5).

Follow all the links above and read also Advanced Linux Programming and Operating Systems: Three Easy Pieces

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547