� Virtual Memory Page buffering (In general) Paging • Evicted pages are kept on two lists: • An important task of a virtual-memory system is to – free and modified page lists relocate pages from physical memory out to disk • Pages are read into the frames on the free • Early UNIX systems swapped out the entire process at page list once • Pages are written to disk in large chunks from • Modern UNIX systems relay more on paging the modified page list • In order to do that Linux too use the paging mechanism • The paging system can be divided to the • If an evicted page is referenced, and it is still on – policy algorithm one of the lists, it is made valid at a very low – paging mechanism cost • Linux’s pageout policy is LFU (least frequently used) Virtual Memory Multiprogramming level Swapping • The paging mechanism support both paging to • Too many processes in memory dedicated swap devices and to files – Thrashing, inability to run new processes • Blocks are allocated from the swap device • The solution is swapping: according to bitmap of used blocks – save all the resident set of a process to the disk (swapping out) • The allocator uses the next fit algorithm – load the pages of another process instead (swapping • When a page is swapped out the page-not- in) present bit is set (or the present is unset) • Long-term and medium term scheduling decides • cat /proc/swaps which processes to swap in/out shows information about the used swap devices kswapd (file mm/vmscan.c) Long (medium) term scheduling • kswapd is a kernel process which reclaim memory from • Decision of which processes to swap the VM subsystem when memory gets low. out/in is based on • We need this to make sure that there will always be free – The CPU usage memory available for interrupts handlers • A regular process goes to sleep until the kernel find free – Creating a balanced job mix with respect to memory (from other processes for example) I/O vs. CPU bound processes • We don’t want an interrupt handler to sleep, so we keep • Two new process states: a certain level of free memory frames. • If we go below this level the kswapd free more memory – Ready swapped – Blocked swapped
Recommend
More recommend