Artificial Intelligence
Artificial Intelligence
Artificial Intelligence
(Chaper 4, Tanenbaum)
seconda main
ry memo
storage ry
K
B B
A A
..
Operati Operati Operati
. Operati
ng ng ng ng
System System System System
B. Best Fit
C. Worst Fit
First Fit:
• In the first fit, the partition is allocated which is the first
sufficient block from the top of Main Memory.
• It scans memory from the beginning and chooses the first
available block that is large enough.
• Thus it allocates the first hole that is large enough.
Best Fit
• Allocate the process to the partition which is the first
smallest sufficient partition among the free available
partition.
SWAP-
IN
Operati
SWAP-OUT ng
Swapping device System
(usually, a hard Memory
disk)
July 99
M emory M gmt 19
Copyright © 1996–2002 Eskicioglu
Swapping cont.
SWAPPER DI SPATCH E R
Segment # Offset
fault!
Physical Address
Page table
0 Page Table Entry (PTE)
1
2
3
4
5
6
7
Physical
Address
1 300 8
Physical Physical
Address Memory
Initially all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4 Page faults.
0 is already there so —> 0 Page fault.
when 3 came it will take the place of 7 because it is not used for the longest duration of time in the
future.—>1 Page fault.
0 is already there so —> 0 Page fault.
4 will takes place of 1 —> 1 Page Fault.
Now for the further page reference string —> 0 Page fault because they are
already available in the memory.
Optimal page replacement is perfect, but not possible in practice as the
operating system cannot know future requests.
Least Recently Used
IIn this algorithm page will be replaced which is least recently
used.
Example-2:Consider the page references 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, with
4 page frame. Find number of page fault.
Initially all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4 Page faults
0 is already there so —> 0 Page fault.
when 3 came it will take the place of 7 because it is least recently used —>1 Page fault
0 is already there so —> 0 Page fault.
4 will takes place of 1 —> 1 Page Fault.
Now for the further page reference string —> 0 Page fault because they are
already available in the memory.
Thrashing
Thrashing is a condition or a situation when the system is
spending a major portion of its time in servicing the page
faults, but the actual processing done is very negligible.
Techniques to handle:
1. Working Set Model –
• The basic principle states that if we allocate enough frames to a process to
accommodate its current locality, it will only fault whenever it moves to
some new locality.
• But if the allocated frames are lesser than the size of the current locality,
the process is bound to thrash.
• According to this model, based on a parameter A, the working set is defined
as the set of pages in the most recent ‘A’ page references.
• Hence, all the actively used pages would always end up being a part of the
working set.