Main Memory Allocation;The objective of this week's lab is to simulate allocation/deallocation of memory. Assume that the memory is 256...
Main Memory Allocation;The objective of this week's lab is to simulate allocation/deallocation of memory. Assume that the memory is 256 KB and is divided into units of 1 KB each. A process may request between 3 and 10 units of memory.;For each process you need to save the process id, the process? allocated location in memory, the number of memory units allocated to the process, and memory used in Byte. The location is the first memory unit allocated to that process. User will specify the number of memory units and memory used is the number of memory units times the size of each unit which in this case is 1 KB.;Allocation/deallocation technique for this lab;For allocation, the user specifies the process id of the process for which memory is requested as well as the number of memory units being requested. Start location for each process is the first free memory unit coming right after the last allocated memory unit. So processes follow each other in memory without any hole between processes. The first process starts from memory unit 0. Let?s assume the user requests to allocate 5 memory units to this process. Then memory locations 0-4 get allocated to this process and the next process? allocation should start from memory unit 5.;For deallocation, the user 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. Then all the following processes in memory should move upwards (shifted up) as many memory units as the deallocated process had. This avoids creating any hole in the memory as the deallocated memory is effectively reoccupied by the following processes.;Command Menu;Your program starts with a menu consisting of these commands (prompt the user to select from the menu);A) Allocate the specified number of memory units to the specified process;D) Deallocate memory of the specified process;R) Report Process and Memory status of the system;E) Exit the Memory Management program;Explanation of each command;A) Allocate the specified number of memory units to the specified process;For this command your program prompts the user to enter the id for the process. You should make sure that the entered id is a number between 1 to 20 and also not already in the system. Then another prompt asks the user to enter a number between 3 to 10, as the number of memory units the user wants to allocate to the process. For the very first process memory allocation starts from location 0. The following allocations all start from the end of previous memory allocation (causing no hole in memory allocation). Effectively, this would be the first free memory unit coming right after the last allocated memory unit. Every time this command is selected by the user, a new process should be created and some units of memory specified by the user are allocated to that process (every new allocation adds a new row to the memory allocation table).;D) Deallocate memory of the specified process;For deallocation requests, the user 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 (no partial deallocation is supported). As part of a deallocation execution, as explained earlier, all the following processes are moved upwards by the number of memory units of the deallocated process. This is implemented by shifting/adjusting the memory allocation addresses for all following processes. The deallocated process row in the output table should also be deleted. You should update the values for Total Memory Used and Total Memory Units too. Total Memory Units new value should be the old value minus number of memory units of the deleted process. Total Memory Used new value should be the old value minus the amount of memory used for the deleted process.;R) Report Process and Memory status of the system;For report you need to create the following table. The table has four columns and one row for each process. You need to evaluate and show the value of two other parameters: Total Memory Used and Total Memory Units. These two parameters are evaluated based of memory usage of all processes.;The following shows an example.;PID;Start Location;# of Units;Memory Used;1;0;5;5000;4;5;3;3000;Total Memory Used: 8 000;Total Memory Units: 8;PID ? Process ID, the number the user enters;Start Location ? the location of the first memory unit where the program starts;# of Units ? number of memory units allocated to a process, the number the user enters;Memory Used ? the amount of memory in bytes allocated to each process;E) Exit the Memory Management program;Exit the program.;Note: The memory allocation/deallocation technique described in this lab is not a method used in real life computer systems. It's a simplified method showing covering some of the characteristics of memory management allocation.
Paper#70272 | Written in 18-Jul-2015Price : $22