0% found this document useful (0 votes)
48 views2 pages

Example: (Memory Management)

The document summarizes how first-fit, best-fit, and worst-fit memory allocation algorithms would allocate memory partitions of varying sizes to processes of different sizes. For first-fit, it allocates the first process (P1) to the second largest partition. It then allocates subsequent processes (P2 and P3) until the largest process (P4) cannot fit. It then evicts the longest residing process (P1) to allocate P4 to its space. First-fit makes sequential allocations without regard for optimal space usage, making it the least efficient of the algorithms described. Best-fit and worst-fit are not explained in detail.

Uploaded by

Aman Baze
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views2 pages

Example: (Memory Management)

The document summarizes how first-fit, best-fit, and worst-fit memory allocation algorithms would allocate memory partitions of varying sizes to processes of different sizes. For first-fit, it allocates the first process (P1) to the second largest partition. It then allocates subsequent processes (P2 and P3) until the largest process (P4) cannot fit. It then evicts the longest residing process (P1) to allocate P4 to its space. First-fit makes sequential allocations without regard for optimal space usage, making it the least efficient of the algorithms described. Best-fit and worst-fit are not explained in detail.

Uploaded by

Aman Baze
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Example: (memory management)

Given five memory partitions of 100 KB, 500 KB, 200 KB, 300 KB, and 600 KB (in order), how
would each of the first-fit, best-fit, and worst-fit algorithms place processes of 212 KB(P1), 417
KB(P2), 112 KB(P3), and 426 KB(P4) (in order)?
Which algorithm makes the most efficient use of memory?
Solution
For first fit

100KB 500KB 200KB 300KB 600KB

first scan the list from the beginning until a hole big enough to hold the process is found. The
first process(P1) has 212 KB therefore the first fit will be the second space (500 KB). Now the
memory partitions look like this (the shaded part is ocupied)

100KB 500KB(212 is 200KB 300KB 600KB


used )
P1
The next process(P2) has 417KB so the next partition that is allocated for it will be the 600 KB
partition

100KB 500KB(212 is 200KB 300KB 600KB(417 KB


used ) is used )
P1 P2
The next process (P3) has 112KB. Therefore the next partition to be allocated is going to be
200KB

100KB 500KB(212 is 200KB(112KB 300KB 600KB(417 KB


used )P1 is used )P3 is used )P2

The next process has 426KB. For this process there is no space that is enough for it. Therefore
the process that has stayed for a long time is removed from the memory(In this particular
example we are not given with an information about the algorithm that is used in removing the
process from the memory. Therefore we assumed that the process that was allocated will be
removed first). In this case the longest process that has stayed is the P1 (on the second partition).
This space is enough for our process. So we allocate it to that memory. If it wasn’t enough, we
should continue removing the next longest staying process, which in our case is the process P2
occupying the 600KB memory.

100KB 500KB(426 KB 200KB(112KB 300KB 600KB(417 KB


is used ) is used ) is used )
P4 P3 P2

For best fit and worst fit follow this step and work.

You might also like