0

Principles of virtual memory:

The idea of virtual memory is to create a virtual address space that doesn't correspond to actual addresses in RAM. The system stores the official copy of memory on disk and caches only the most frequently used data in RAM. To make this workable, we break virtual memory into chunks called pages; a typical page size is four kilobytes. We also break RAM into page frames, each the same size as a page, ready to hold any page of virtual memory.

I'm running a Linux system and the swap area is empty, because there's enough space in main memory. That being said, is there still a virtual memory with pages and will processes continue to have virtual addresses instead of the physical addresses of their segments in the main memory?

What if there's no swap area in disk, is there a virtual memory in the system too?

In simple words, is virtual memory always available in a Linux system and will process always have virtual addresses?

  • 1
    After paging has been turned on in the CPU early in the kernel boot process, all running code uses virtual addresses, including user space code and kernel code. – Johan Myréen Jul 4 '17 at 20:14
1

Virtual memory (paging) is enabled on CPU level. That means CPU uses MMU to convert virtual address (as it seen by application) to physical address. Memory is splitted to pages. Page could be either loaded to memory or loaded to disk. If page is on disk then accessing this page leads to page fault which is processed by OS (OS loads page from disk).

So if you have no swap you still have virtual memory, CPU still uses MMU and splits memory into pages but OS cant move page to disk.

http://wiki.osdev.org/Paging

  • Then the CPU also maintains the page table? – direprobs Jul 4 '17 at 20:23
  • Yes, as always. Paging is not only used for swap. It also used for security (W^X/DEP etc). Simply disabling swap does not disable virtual memory. – user996142 Jul 4 '17 at 20:30
  • That's to say there would be no virtual pages and processes have only page frames in physical memory. Because there's nothing stored at disk. However, those processes are still given virtual addresses. I'm not sure if I got this right. So to some process they could have page frames without having pages? – direprobs Jul 4 '17 at 21:02
  • 1
    The term virtual memory does not primarily refer to the fact that pages don't have mappings to physical pages, swapping to backing storage is just a secondary mechanism. The term virtual in this context is related to that each process is presented with its own address space starting from address zero, that is decoupled from the physical address space. This is why it is called virtual. The MMU handles the mapping between virtual and physical addresses, but the operating system maintains a separate mapping for each proecss, and switches the active mapping when scheduling processes. – Johan Myréen Jul 5 '17 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.