Mohammad Saddam Mashuri's OS202
Virtual Memory: Definition
Back to the fundamentals. Virtual Memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory. This is a technique that is used in both hardware and software. Essentially, It maps memory addresses used by a program, called virtual addresses, into physical addresses in computer memory.
Virtual Address Space (VAS)
This is similar to point no. 1 on week 4 of the top 10 list. To reiterate, the address space allows the OS to create an easy to use abstraction of physical memory. While virtual address space (VAS) is the set of ranges of virtual addresses that an operating system makes available to a process. Which means that, each time a process is run on an OS, the OS creates a new process and a new VAS for this process. This gives various benefits, one of which is process isolation, which protects each process from other processes on the OS.
Demand Paging
Demand paging loads a page in memory on-demand or when a page fault occurs. Demand paging is a method of virtual memory management. To achieve this process, a page table implementation is used. The page table maps logical memory to physical memory. One of the advantages of demand paging is that memory would be used more efficiently, and we can have a large virtual memory.
Page Fault
A page fault happens when a program tries to access a block of memory that is not stored in the physical memory, or RAM. Most page faults are handled without problems. However, an invalid page fault may cause a program to freeze or crash. Preventive measures, like page fault handling, should be implemented into a program, as page faults are quite common in the OS.
Memory API
Memory allocation interfaces that are provide in UNIX systems, are quite simple. There are two types of memory that are allocated. The first is called stack memory, and allocations and deallocations of it are managed implicitly by the programmer. The second one is called, heap memory. This is used for long-lived memory, where all allocations and deallocations are explicitly handled by the programmer.
Thrashing
When a page fault and swapping occur frequently at a high rate, then the OS need to spend more time to swap the pages. This state is called thrashing. When thrashing occur, the CPU performance is reduced. The current best practice to handle thrashing, is to include enough physical memory, whenever possible, to avoid thrashing.
Sources:
Abraham Silberschatz - Operating System Concepts -Wiley (2018)
http://pages.cs.wisc.edu/~remzi/OSTEP/
http://dictionary.sensagent.com/Virtual%20address%20space/en-en/
https://www.tutorialandexample.com/what-is-demand-paging/
https://techterms.com/definition/page_fault
https://en.wikipedia.org/wiki/Page_replacement_algorithm