Question
Q1. [15 points] Consider a memory of size 16KB. This memory is allocated in increments of 1KB and the memory is initially empty. Use the
Q1. [15 points] Consider a memory of size 16KB. This memory is allocated in increments of 1KB and the memory is initially empty. Use the various contiguous allocation schemes (First-fit, Best-fit, and Worst-fit) for satisfying the memory allocation/deallocation requests for processes requesting the sizes shown in the table below.
Process | A | B | C | D | E | F | G | H | I | J |
Requested size (in KB) | 4.2 | 7.2 | 2.5 | 4.5 | 3 | 2.7 | 1.5 | 2 | 3.6 | 1 |
Allocate(P) represents an allocation request by process P for the size shown in the above table
Deallocate(P) is used to indicate deallocating the memory allocated to process P
To represent memory, in square brackets, we use P to indicate a memory segment allocated to P and we use an integer to indicate a contiguous free part of memory. For example, after the following sequence of requests: Allocate(B), Allocate(G), Allocate(H), Deallocate(G) memory will look like this:
We represent this memory by [B,2,H,4].
For each of the following sequence of requests, apply the First-fit, Best-fit, and Worst-fit allocation schemes. Assume that for each algorithm, you always start at the beginning of the list and if there are multiple possible equal-size holes that can be selected by an algorithm, the first one is selected. Show the following:
- If all the requests can be satisfied, indicate the memory representation at the end of the sequence. If a request cannot be satisfied by an algorithm, indicate which request is this and the memory representation at this point. For example, consider adding the request Allocate(X) to the previous example. The following are answer examples
If X is requesting 6 KB the answer will be:
[B,2,H,4] and Allocate(X) cannot be satisfied
If X is requesting 3 KB, the answer will be
[B,2,H,X,1]
- Which method is the best for this particular sequence, and the amount (in KB) of internal fragmentation at the end of the sequence for this best method.
Enter your answers in the tables below.
[Grading: 1 point for each answer]
Request Sequence: Allocate(A), Allocate(B), Allocate(C), Deallocate(A), Deallocate(C), Allocate(E), Allocate(D) | ||
First-fit | Best-fit | Worst-fit |
|
|
|
The best algorithm for this sequence of requests is: _____________________
The amount of internal fragmentation (in KB) for this algorithm is ________________
|
Request Sequence: Allocate(C), Allocate(B), Allocate(A), Deallocate(C), Deallocate(A), Allocate(G), Allocate(E), Allocate(F) | ||
First-fit | Best-fit | Worst-fit |
|
|
|
The best algorithm for this sequence of requests is: _____________________
The amount of internal fragmentation (in KB) for this algorithm is ________________
|
c)
Request Sequence: Allocate(I), Allocate(G), Allocate(H), Allocate(A), Deallocate(I), Deallocate(H), Deallocate(A), Allocate(J), Allocate(E), Allocate(H), Allocate(D) | ||
First-fit | Best-fit | Worst-fit |
|
|
|
The best algorithm for this sequence of requests is: _____________________
The amount of internal fragmentation (in KB) for this algorithm is ________________
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started