The following sequence of requests in bytes is issued to mem
The following sequence of requests (in bytes) is issued to memory management manager with variable programming.
1) Allocate block b1 of size 100
2) Allocate block b2 of size 500
3) Allocate block b3 of size 60
4) Allocate block b4 of size 100
5) Release block b1
6) Release block b3
7) Allocate block b5 of size 50
8) Allocate block b6 of size 90
9) Release block b4
10) Allocate block b7 of size 200
Assume a total memory of 1024 bytes. Draw a diagram of the memory that shows what parts of memory are allocated and what parts of memory are free (list the starting address of each block and the sizes of each block including free spaces) as each of the above requests are processed for:
a) First Fit
b) Best Fit
c) Worst Fit
Solution
Answer:
The following sequence of requests (in bytes) is issued to memory management manager with variable programming.
1) Allocate block b1 of size 100
2) Allocate block b2 of size 500
3) Allocate block b3 of size 60
4) Allocate block b4 of size 100
OS
B1 - 100bytes
B2 - 500bytes
B3 - 60bytes
B4 - 100bytes
<free> 264bytes
First allocating four blocks
-> Release block b1 and b3
OS
<free>100bytes
B2 - 500bytes
<free> 60bytes
B4 - 100bytes
<free>264bytes
1. First fit:
->Allocate block b5 of size 50
OS
B5 - 50bytes
<free>50bytes
B2 - 500bytes
<free> 60bytes
B4 - 100bytes
<free> 264bytes
Allocate block b6 of size 90
OS
B5 - 50bytes
<free>50bytes
B2 - 500bytes
<free> 60bytes
B4 - 100bytes
B6 - 90bytes
<free>174bytes
9) Release block b4
OS
B5 - 50bytes
<free>50bytes
B2 - 500bytes
<free> 60bytes
<free>100bytes
B6 - 90bytes
<free>174bytes
//release B4
10) Allocate block b7 of size 200
No free block that is large enough for the new Block b7
But actually 384 bytes memory is empty
b) Best Fit:
Allocate block b5 of size 50
OS
<free>100bytes
B2 - 500bytes
B5 - 50bytes
<free> 10bytes
B4 - 100bytes
<free>264bytes
Allocate block b6 of size 90
OS
<free>10bytes
B2 - 500bytes
B5 - 50bytes
<free> 10bytes
B4 - 100bytes
<free>264bytes
9) Release block b4
OS
<free>10bytes
B2 - 500bytes
B5 - 50bytes
<free> 10bytes
<free>100bytes
<free>264bytes
Allocate block b7 of size 200
OS
<free>10bytes
B2 - 500bytes
B5 - 50bytes
<free> 10bytes
<free>100bytes
<free>64bytes
3.Worst Fit:
Allocate block b5 of size 50
OS
<free>100bytes
B2 - 500bytes
<free> 60bytes
B4 - 100bytes
<free>214bytes
Allocate block b6 of size 90
OS
<free>100bytes
B2 - 500bytes
<free> 60bytes
B4 - 100bytes
<free>124bytes
Release block b4
OS
<free>100bytes
B2 - 500bytes
<free> 60bytes
<free>100bytes
<free>124bytes
10) Allocate block b7 of size 200
ans) No free block that is large enough for the new Block b7,
But actually 384 bytes memory is empty
***********************Best fit is perfect for variable memory management technic************************
| OS |
| B1 - 100bytes |
| B2 - 500bytes |
| B3 - 60bytes |
| B4 - 100bytes |
| <free> 264bytes |




