Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2: Main Memory Allocation Goal: To simulate and evaluate different memory allocation/deallocation techniques, first fit, best fit, and worst fit, when a linked list
Problem 2: Main Memory Allocation Goal: To simulate and evaluate different memory allocation/deallocation techniques, first fit, best fit, and worst fit, when a linked list is used to keep track of memory usage Assume that the memory is 256 KB and is divided into units of 2 KB each. A process may request between 3 and 10 units of memory Your simulation consists of three components: Memory component that implements a specific allocation/deallocation technique; Request generation component that generates allocation/deallocation requests; Statistics reporting component that prints out the relevant statistics. The Memory component exports the following functions: 1. int allocate mem (int process_id, int num_units): allocates num_units units of memory to a process whose id is process_id. If successful, it returns the number of nodes traversed in the linked list. Otherwise, it returns -1 2. int deallocate_mem (int process_id): deallocates the memory allocated to the process whose id is process_id. It returns 1, if successful, otherwise -1. 3. int fragment count: returns the number of holes (fragments of sizes 1 or 2 units) You will implement a separate Memory component for each memory allocation/deallocation technique The request generation component generates allocation and deallocation requests. For allocation request, the component specifies the process id of the process for which memory is requested as well as the number of memory units being requested. For this simulation, assume that memory is requested for each process only once. For deallocation requests, the component specifies the process id of the process whose memory has to be deallocated. For this simulation, assume that the entire memory allocated to a process is deallocated on a deallocation request. You may generate these requests based on some specific criteria, e.g. at random or from a memory allocation/deallocation trace obtained from some source There are three performance parameters that your simulation should calculate for all four techniques Average number of external fragments; Average allocation time in terms of the average number of nodes traversed in allocation; The percentage of times an allocation request is denied Generate 10,000 requests using the request generation component, and for each request, invoke the appropriate function of the Memory component for each of the memory allocation/deallocation technique. After every request, update the three performance parameters for each of the techniques. Note we'll pre load the simulation with 20 tasks with a random selection of between 3 and 10 units of memory The statistics reporting component prints the value of the three parameters for all four techniques at the end. What does the simulation tell us about the different memory allocation techniques? Problem 2: Main Memory Allocation Goal: To simulate and evaluate different memory allocation/deallocation techniques, first fit, best fit, and worst fit, when a linked list is used to keep track of memory usage Assume that the memory is 256 KB and is divided into units of 2 KB each. A process may request between 3 and 10 units of memory Your simulation consists of three components: Memory component that implements a specific allocation/deallocation technique; Request generation component that generates allocation/deallocation requests; Statistics reporting component that prints out the relevant statistics. The Memory component exports the following functions: 1. int allocate mem (int process_id, int num_units): allocates num_units units of memory to a process whose id is process_id. If successful, it returns the number of nodes traversed in the linked list. Otherwise, it returns -1 2. int deallocate_mem (int process_id): deallocates the memory allocated to the process whose id is process_id. It returns 1, if successful, otherwise -1. 3. int fragment count: returns the number of holes (fragments of sizes 1 or 2 units) You will implement a separate Memory component for each memory allocation/deallocation technique The request generation component generates allocation and deallocation requests. For allocation request, the component specifies the process id of the process for which memory is requested as well as the number of memory units being requested. For this simulation, assume that memory is requested for each process only once. For deallocation requests, the component specifies the process id of the process whose memory has to be deallocated. For this simulation, assume that the entire memory allocated to a process is deallocated on a deallocation request. You may generate these requests based on some specific criteria, e.g. at random or from a memory allocation/deallocation trace obtained from some source There are three performance parameters that your simulation should calculate for all four techniques Average number of external fragments; Average allocation time in terms of the average number of nodes traversed in allocation; The percentage of times an allocation request is denied Generate 10,000 requests using the request generation component, and for each request, invoke the appropriate function of the Memory component for each of the memory allocation/deallocation technique. After every request, update the three performance parameters for each of the techniques. Note we'll pre load the simulation with 20 tasks with a random selection of between 3 and 10 units of memory The statistics reporting component prints the value of the three parameters for all four techniques at the end. What does the simulation tell us about the different memory allocation techniques
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