next fit and other techniques).
Select and simulate one of these techniques for lab4 and select another technique for lab5.
Assumptions:
Memory is 256K.
Each unit is 2K. Therefore, there are 128 units that can be allocated to different processes.
A process may request between 3 and 10 units of memory
Number of requests: 10,000
Based on the above assumptions, three constants are defined in the code as follows:
#define NUM_REQUESTS 10000
#define MIN_NUM_UNITS 3
#define MAX_NUM_UNITS 10
A class is which has two member variables called process_id and num_units.
Also a list of nodes needs to be defined.
At start all the units are available. We can use -1 as the process_id to represent availability (hole). The the list at the start where the 128 units is available for allocation. Note however, a process can only ask for up to 10 units of allocation.
-1 | 128 |
The program uses a to randomly select between allocation and deallocations. The deallocations can happen if there is at least one process that memory is allocated for it.
You can keep track of the list of processes that the memory is currently being allocated to them. Then during the deallocation, you may randomly select one process from this list and deallocate memory for that process.
Each allocation or deallocation is considered as one request. You must also keep track of number of requests since we want to have 10,000 requests in this simulation.
Each process may request 3 to 10 units of memory. Therefore, number of unit requested by each process is a random number in the range 3 to 10. You may use a and at the end of each allocation request, you may increment that variable for the next process ID request.
You may use a for loop to check the list to see if there is a hole big enough for the given request as follows:
for (list<Node>::iterator cur = memory_list.begin(); cur != memory_list.end(); ++cur) {
As you check each node, if a node has a process id of -1 and the size of it is equal or greater than the requested number of units then allocation is possible.
You need to modify the list by inserting a node with the and given number of units requested.
Example:
If process 0 requests 5 units, then the above list becomes:
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more