Refactor Code (MemoryManagementAlgorithms): Pull Up Variable (#4145)
This commit is contained in:
parent
7779c18ef6
commit
181906d5f7
@ -25,6 +25,18 @@ public abstract class MemoryManagementAlgorithms {
|
|||||||
int[] sizeOfBlocks,
|
int[] sizeOfBlocks,
|
||||||
int[] sizeOfProcesses
|
int[] sizeOfProcesses
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A constant value used to indicate that an allocation has not been made.
|
||||||
|
* This value is used as a sentinel value to represent that no allocation has been made
|
||||||
|
* when allocating space in an array or other data structure.
|
||||||
|
* The value is -255 and is marked as protected and final to ensure that it cannot be modified
|
||||||
|
* from outside the class and that its value remains consistent throughout the program execution.
|
||||||
|
*
|
||||||
|
* @author: Ishan Makadia (github.com/intrepid-ishan)
|
||||||
|
* @version: April 06, 2023
|
||||||
|
*/
|
||||||
|
protected static final int NO_ALLOCATION = -255;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,9 +44,6 @@ public abstract class MemoryManagementAlgorithms {
|
|||||||
*/
|
*/
|
||||||
class BestFitCPU extends MemoryManagementAlgorithms {
|
class BestFitCPU extends MemoryManagementAlgorithms {
|
||||||
|
|
||||||
private static final int NO_ALLOCATION = -255; // if a process has been allocated in position -255,
|
|
||||||
|
|
||||||
// it means that it has not been actually allocated.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to find the maximum valued element of an array filled with
|
* Method to find the maximum valued element of an array filled with
|
||||||
@ -115,10 +124,6 @@ class BestFitCPU extends MemoryManagementAlgorithms {
|
|||||||
*/
|
*/
|
||||||
class WorstFitCPU extends MemoryManagementAlgorithms {
|
class WorstFitCPU extends MemoryManagementAlgorithms {
|
||||||
|
|
||||||
private static final int NO_ALLOCATION = -255; // if a process has been allocated in position -255,
|
|
||||||
|
|
||||||
// it means that it has not been actually allocated.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to find the index of the memory block that is going to fit the
|
* Method to find the index of the memory block that is going to fit the
|
||||||
* given process based on the worst fit algorithm.
|
* given process based on the worst fit algorithm.
|
||||||
@ -179,9 +184,6 @@ class WorstFitCPU extends MemoryManagementAlgorithms {
|
|||||||
*/
|
*/
|
||||||
class FirstFitCPU extends MemoryManagementAlgorithms {
|
class FirstFitCPU extends MemoryManagementAlgorithms {
|
||||||
|
|
||||||
private static final int NO_ALLOCATION = -255; // if a process has been allocated in position -255,
|
|
||||||
|
|
||||||
// it means that it has not been actually allocated.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to find the index of the memory block that is going to fit the
|
* Method to find the index of the memory block that is going to fit the
|
||||||
@ -237,8 +239,6 @@ class FirstFitCPU extends MemoryManagementAlgorithms {
|
|||||||
*/
|
*/
|
||||||
class NextFit extends MemoryManagementAlgorithms {
|
class NextFit extends MemoryManagementAlgorithms {
|
||||||
|
|
||||||
private static final int NO_ALLOCATION = -255; // if a process has been allocated in position -255,
|
|
||||||
// it means that it has not been actually allocated.
|
|
||||||
private int counter = 0; // variable that keeps the position of the last registration into the memory
|
private int counter = 0; // variable that keeps the position of the last registration into the memory
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user