Professional Documents
Culture Documents
Background Logical Versus Physical Address Space Swapping Paging Virtual Memory Demand Paging Thrashing
Background
Program must be brought into memory and placed within a process for it to be executed Input queue collection of processes on the disk that are waiting to be brought into memory for execution. User programs go through several steps before being executed.
Address Binding
Address binding of instructions and data to memory addresses can happen at three different stages. -Compile Time -Load Time -Execution Time
Dynamic Loading
Routine is not loaded until it is called Better memory-space utilization Useful for large amount of code are needed No special support from the OS is required
Dynamic Linking
Linking postponed until execution time. Stub used to locate the appropriate memoryresident library routine. OS needed to check if routine is in processes memory address.
CPU
Memory
MMU
SWAPING
A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution swapping can be done on priority bases A process that is swapped out will be swapped back into the same memory space that is occupied previously
Paging
Physical memory is broken into fixed size blocks called frames logical memory is broken into blocks of same size called pages paging is done with the hardware support
Paging
Logical address CPU P d F d Physical Page table Memory
Paging hardware
Paging
E.g u 1 2 3 4 5 6 7 8 9 10 11 a b c d e f g h i j k l 0 0 1 2 3 3 4 4 1 2 Page table 16 8 I j k l m n o p a b c d e f g h Physical memory
12
Logical Memory
Virtual Memory
Virtual memory separation of user logical memory from physical memory.
Only part of the program needs to be in memory for execution. Logical address space can therefore be much larger than physical address space. Need to allow pages to be swapped in and out.
DemandDemand-paging
Bring a page into memory only when it is needed -Less I/O needed -Less memory needed -Faster response -more users Page in, Page out and Page fault.
Valid-Invalid Bit Valid With each page table entry a valid-invalid bit is associated. Example of a page table snapshot
Frame # valid-invalid bit
1 1 1 1 0 M
DemandDemand-paging
3 OS 2 1 Load M i 6
Free frame 4
Thrashing
If process doesnt have enough pages, the page-fault rate is very high. This leads to: -low CPU utilization -OS thinks that it needs to increase the degree of multiprogramming -another process added to the system Thrashing= a process is busy swapping pages in and out
Thrashing
Causes Of Thrashing:
C P U U t I l I z a t I o n Degree of multiprocessing Thrashing