Given the following memory allocation: a) The addresses shown are in bytes and a
ID: 3852979 • Letter: G
Question
Given the following memory allocation: a) The addresses shown are in bytes and are the starting addresses of each occupied block or 'hole'. b) The blocks (A, B, C, D) are already loaded in memory in the order shown. c) Three new blocks are required in the order shown. E requests a block of 400 bytes F requests a block of 1000 bytes G requests a block of 800 bytes d) The best fit algorithm is used to load the blocks. e) If a request fails, the memory will be compacted according to one of the following methods: Method a: All blocks are shifted towards address 0. Method b: Starting with the lowest address block, blocks are shifted toward address 0 until a large enough hole for the current request is created. Show the memory locations (starting address) for each of the methods (a & b) described above after all 3 requests are satisfied. Method a Method bExplanation / Answer
Best fit memory allocation method:
This memory allocation method will search for the smallest empty block in which that process will fit. So that less memory wasted in that block.
E request:
In our case E requests 400 Bytes block.Now memory manager will search for best block that will fit for the process.
we have holes(empty blocks) of size 800,600,800. The best block will be 600. This is the smallest block and this process also fit in this block.so E request will be saticified by allocating the block with starting address 1600-ending with 2200.
Allocation will be like this
0 800 1600 2200 2800 3600 4000 5000
after saticifying the E request 200 B are wasted in that block.
F request:
F requests 1000 b block . but avaible blocks that are located at 0-800(800 Bytes) and 2800-3600(800 bytes). And those are not contigous also. So F request fails.
memory blocks should be compacted.
here 2 methods are listed above
method a: All blocks re shifted towards 0.
this is compaction process. Processes should be moved/shifted.
compaction process has to be done then our reallocation stratagy should be dynamic.
Here we don't know the exact size of block which A is requested.But we can sure that it is less than or equal to 800 Bytes.because it is loaded into 800-1600 block. A process can be loaded into 0-800 block.
E processs is 400 Bytes
this will be shifted and allocated block is 800-1200B
B process required 600 B and will be allocated 1200-1800B block.
C process required 400B and will be allocated 1800-2200B block.
D process required 1000B and will be allocated 2200-3200B block
0 800 1200 1800 2200 3200 5000
now F request can be saticified and new allocation will be like this
0 800 1200 1800 2200 3200 4200 5000
G requests 800 B block.
0 800 1200 1800 2200 3200 4200 5000
here after 3 requests saticified ,3200B are copied. (0-800 (800), 800-1200(400), 1200-1800(600), 1800-2200(400)
2200-3200(1000) .
here we will do compaction in method B.
E request can be saticified normally.
but F fails due to small size holes. we will do compaction using methid B.
processes should be shifted towards 0 untill large block is find.
F requests 1000 B block.
A can be shifed to 0-800
E can be shifted to 800-1200
now 1200-2200 B block is free. we can load F into that hole.
new allocation is like this.
0 800 1200 2200 2800 3600 4000 5000
Now G process can be saticified normally. no compaction is required
0 800 1200 2200 2800 3600 4000 5000
Here 3 requests staticified only 0-800(800),800-1200 (400) are copied that means only 1200 B are copied.
A E B C DRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.