Professional Documents
Culture Documents
Unit - III: Memory Management and Virtual Memory
Unit - III: Memory Management and Virtual Memory
system call,
1
interrupt, return
interrupt to user
interrupt return return
Preempted
Kernel
2 Running
7
9 preempt
reschedule
Zombie process
sleep
Ready to
4 wakeup
3 Run in Memory
Asleep enough mem
in Created
fork
Memory swap
out swap
out
swap
in
8
not enough mem
6 wakeup 5 (swapping system only)
Address Unit
Allocate 100 unit
1 10000 101 9900
Map
Allocate 50 unit
1 150
251 9750
• Principle of locality
External Fragmentation
• memory becomes more and more fragmented
• memory utilization declines
Compaction
• technique for overcoming external fragmentation
• OS shifts processes so that they are contiguous
• free memory is together in one block
• time consuming and wastes CPU time
Placement Algorithms
Relative
Physical or Absolute
Pages Frames
• chunks of a • available
process chunks of
memory
Page Table
• Maintained by operating system for each process
• Contains the frame location for each page in the process
• Processor must know how to access the page table for the current
process
• Used by processor to produce a physical address
Logical Addresses
Logical-to-Physical Address
Translation - Paging
Segmentation
Compile-time Defenses
• aim to harden programs to resist attacks in new
programs
Run-time Defenses
• aim to detect and abort attacks in existing programs
Translation Lookaside Buffer
• Each virtual memory reference can cause two physical
memory accesses
• One to fetch the page table
• One to fetch the data
• To overcome this problem a high-speed cache is set up for
page table entries
• Called a Translation Lookaside Buffer (TLB)
• Contains page table entries that have been most recently used
Translation Lookaside Buffer
Translation Lookaside Buffer
• Given a virtual address, processor examines the TLB
• If page table entry is present (TLB hit), the frame number is
retrieved and the real address is formed
• If page table entry is not found in the TLB (TLB miss), the page
number is used to index the process page table.