1 Describe a presentday computing environment that might use
Solution
Memory Allocation:Memory allocation is the process of assigning blocks of memory on request. Typically the allocatorreceives memory from the operating system in a small number of large blocks that it must divide up to satisfy the requests for smaller blocks. It must also make any returned blocks available for reuse.The various allocation algorithms are given as:
1) First fit
2) Best fit
3) Worst fit
4) Next fit
1) First fit: In the first fit algorithm, the allocator keeps a list of free blocks (known as the free list) and, on receiving a request for memory, scans along the list for the first block that is large enough to satisfy the request. If the chosen block is significantly larger than that requested, then it is usually split, and the remainder added to the list as another free block.It finishes after finding the first suitable free partition.
Advantage: Fastest algorithm because it searches as little as possible
Disadvantage: The remaining unused memory areas left after allocation become waste if it is too smaller. Thus request for larger memory requirement cannot be accomplished.
2) Best fit: The best fit deals with allocating the smallest free partition which meets the requirement of the requesting process. This algorithm first searches the entire list of free partitions and considers the smallest hole that is adequate. It then tries to find a hole which is close to actual process size needed.It tries to find a hole which is close to actual size needed.
Advantage:Memory utilization is much better than first fit as it searches the smallest free partition first available.
Disadvantage: It is slower and may even tend to fill up memory with tiny useless holes.
3) Worst fit:In worst fit approach is to locate largest available free portion so that the portion left will be big enough to be useful. It is the reverse of best fit.
4) Next fit: Next fit is a modified version of first fit. It begins as first fit to find a free partition. When called next time it starts searching from where it left off, not from the beginning.
Form the given information in the problem 7:
a) For the best fit algorithm,allocates the smallest free partition which meets the reqirement without wasting much memory.So
Job A needs 57k so it can fit in any block of the four. but it takes Block 3 so that much memory is not wasted.
Job B needs 920k it cannot fit in both Block 2 and block 1,but it has to use two blocks to fit.Even so much memory is wasted so it fits in Block 2 and takes remaining from other block.
Job C also fits in block 3
Job D can fit in Block 1 and 2 but it fits in block 1 as block 2 is used.
b) For the first fit algorithm,means pick the first block that meets the requirment.
For Job A, it takes first block 1
Job B it takes block 2 but does not fit so it has to wait for Job A
Job C it takes block 3 as per the requirement.
Job D it takes Block 4 but does not fit so it has to wait for other blocks as Job A or Job C to finish which has free space and then fits.
For the given problem 8:
For Job A it takes for the block 1 and uses it 100k in it and then takes for block 2 for remaining to fit in it.The unused memory in block 2 would be 410k.
For job B it takes for the block 2 and use 50k so remains 360k
For job C it takes block 2 and uses 275k and the remaining memory of the block 2 is 85k
For job D,it takes block 2 which has 85k and uses it and then moves to block 3 uses it and for remaining 95k it moves to block 4 and uses 95k thus leaving 500k remaining unused in block 4.
The advantage of next fit is such that,when a new job is called it searches from the remaining block of memory so that much space is saved rather than wasting some amount of space in each block.Thus speed also is imprived in next fit since if memory is released that is earlier in the heap for an application,it will check for that block first and fits there.

