Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If we have infinite memory, then do we still be needing paging?

Paging creates illusion that each process has infinite RAM by moving pages to and from disk. So if we have infinite memory(in some hypothetical situation), do we still need Paging? If yes, then why? I faced this question in an interview.

like image 919
Sreeja Das Avatar asked Jan 08 '13 11:01

Sreeja Das


People also ask

Do I need virtual memory if I have enough RAM?

Therefore, no matter how large the capacity of RAM is, it's still necessary for us to enable the virtual memory. Another thing about virtual memory is that Windows only uses paging files when it's necessary. In other words, Windows does not use paging files all the time.

Is paging necessary?

Paging is a function of memory management where a computer will store and retrieve data from a device's secondary storage to the primary storage. Memory management is a crucial aspect of any computing device, and paging specifically is important to the implementation of virtual memory.

Why do we need memory paging?

Paging allows the cumulative total of virtual address spaces to exceed physical main memory. A process can store data in memory-mapped files on memory-backed file systems, such as the tmpfs file system or file systems on a RAM drive, and map files into and out of the address space as needed.

Can we have an infinite amount of virtual memory?

Virtual memory is the summation of RAM and available hard disk space in most cases. As the summation is a countable number, it can't be infinity.


1 Answers

Assuming that "infinite memory" means infinite randomly accessable memory, or RAM, we will still need paging. Although paging is often associated with the ability to swap pages in and out of RAM to a hard disk to conserve memory, this is merely one aspect of paging. Here are some other reasons to have paging:

  • Security. Paging is a method to enforce operating system security and memory protection by ensuring that a processes cannot access the memory of another process and that it cannot modify the resident kernel.
  • Multitasking. Paging aids in multitasking by virtualizing the memory space, that is, address 0xFOO in Process A can be something completely different than 0xFOO in Process B
  • Memory Allocation. Paging aids in memory allocation by reducing fragmentation and ensuring RAM is only allocated when accessed. What this means is that although a process needs, suppose, 100MB of continuous RAM space, this need not be continuous physically. Additionally, when a program requests 100MB of space, the operating system will tell the program it's safe to use that 100MB of space, yet it will not be actually allocated until the program uses that space to its fullest.

Admittedly, the latter would not be entirely necessary if one had infinite RAM, nonetheless; it is always good practice to be eifficient even when we are not resource constrained. It also demonstrates a use for paging that is sometimes not considered.

like image 107
Dougvj Avatar answered Sep 27 '22 17:09

Dougvj