31
31
&TECHNOLOGY
CA2 ASSIGNMENT
Concept: The simplest page replacement algorithm. Pages are stored in a queue,
and when a new page is needed, the oldest page (the one that was brought in first)
is removed.
How It Works:
1. When a page fault occurs and a new page is loaded into memory, the oldest
page (at the front of the queue) is replaced.
2. Example:
Disadvantage: FIFO may replace frequently used pages, leading to more page
faults. This issue is known as Belady's anomaly, where adding more memory
can sometimes increase the number of page faults.
Concept: Replaces the page that will not be used for the longest period in the future.
It results in the least number of page faults.
How It Works:
1. Examines the future use of pages and selects the one that will not be needed
for the longest time.
2. Example:
Concept: Replaces the page that has not been used for the longest period. Pages
used recently are assumed to be more likely to be used again soon.
How It Works:
1. Tracks the order of page accesses and replaces the least recently used page
when a page fault occurs.
2. Example:
Disadvantage: Can be expensive to implement due to the need to track the order of
page references, either by timestamps or stacks.
Concept: Replaces the page that has been used the fewest times, based on the
assumption that pages with low frequency of use are less likely to be accessed
again.
How It Works:
1. Maintains a count of how frequently each page is accessed, and the page with
the smallest count is replaced.
2. Example:
Disadvantage: LFU does not account for recency, so a page that was frequently
used in the past but is no longer needed may remain in memory longer than
necessary.
Summary
The choice of algorithm depends on specific system needs, including memory size,
application behaviour, and performance requirements.