Unit-4 Memory MT
Unit-4 Memory MT
Worst-fit: Allocate the largest hole; must also search entire list
Produces the largest leftover hole
First-fit and best-fit better than worst-fit in terms of speed and storage
utilization
Fragmentation
External Fragmentation – total memory space exists to
satisfy a request, but it is not contiguous
Since the page table is paged, the page number is further divided into:
a 12-bit page number
a 10-bit page offset
Thus, a logical address is as follows:
4
1
3 2
4
.
Virtual Memory That is Larger Than Physical Memory
Demand Paging
A demand-paging system is similar to a paging system with
swapping
Page replacement – find some page in memory, but not really in use, swap
it out.
algorithm
performance – want an algorithm which will result in minimum number of
page faults.
3. Read the desired page into the (newly) free frame. Update the
page and frame tables.
1 1 4 5
2 2 1 3 9 page faults
3 3 2 4
4 frames
1 1 5 4
2 2 1 5 10 page faults
3 3 2
4 4 3
FIFO Page Replacement
Optimal Algorithm
Replace page that will not be used for longest period of time.
4 frames example
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
1 4
2 6 page faults
3
4 5
How do you know this?
Used for measuring how well your algorithm performs.
Optimal Page Replacement
Least Recently Used (LRU) Algorithm
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
1 5
2
3 5 4
4 3
Counter implementation
Every page entry has a counter; every time page is referenced through
this entry, copy the clock into the counter.
When a page needs to be changed, look at the counters to determine
which are to change.
LRU Page Replacement
Allocation of Frames
Each process needs minimum number of pages.
Local replacement – each process selects from only its own set of allocated
frames.
Thrashing
If a process does not have “enough” pages, the page-fault rate is very high.
This leads to:
low CPU utilization.
operating system thinks that it needs to increase the degree of
multiprogramming.
another process added to the system.
The process by which the kernel of the operating system allocates memory
for its internal operations and data structures is called kernel memory
allocation.“
Once the block of the desired size is found, the allocator marks it as allocated