Consider following algorithms for placing processes into holes in memory: best fit. Your assignment is to write a simulator that will take processes of varying sizes, load them into memory according to each of those rules, and swap processes out as needed to create a larger hole. Following assumptions are made:
1. Memory size is 128MB
2. Size of each process will be some number (integer) in the range 1 to 128MB.
3. An initial list of processes and their sizes is loaded from a file. These processes should be loaded into a queue of processes waiting to be loaded into memory.
4. Memory is initially empty. (We will ignore the operating system.)
5. If a process needs to be loaded but there is no hole large enough to accommodate it, then one or several processes should be swapped out, one at a time, until there is a hole large enough to hold the process that needs to be loaded.
6. If processes need to be swapped out, then the process that has been “in memory” the longest should be the one to select.
7. When a process has been swapped out, it goes to the end of the queue of processes waiting to be swapped in.
8. Once a process has been swapped out for a third time, we assume that that process has run to completion, and it is not re-queued. Note: not all processes will be necessarily swapped out for a third time.
9. The simulation terminates when the queue of processes are empty.
The "process file" will be in the following format:
Process id <space> process size (an integer).
Here is a sample process file:
Your program should do the following:
1. Each time a process is loaded into memory, a memory map and statistics line should be printed as according to following example:
2. Memory Map showing all the memory filled and empty.
Number of processes in memory = 5
Number of holes = 3
Memory usage = 41%,
Cumulative memory = 40
• Memory usage refers to the percent of memory that is currently occupied by processes,
• Cumulative memory (in percent) gives the average of all the memory usage up until and including the current process load.
4. When the queue is empty, following should be printed:
Total process loaded = 33
Average number of processes in memory= 14.4
Average number of holes = 6.3
9 фрилансеров(-а) готовы выполнить эту работу в среднем за $189
This problem can be solved in java by making a class to represent the process and apply the rules accordingly as required in the project. With me everything will be done according to the requirements.