Проблема в том, что мой код ведет себя странно, и я не знаю почему. Кажется, что он пропускает выделение всех остальных процессов, поэтому он «загружает» 102, но пропускает 102, загружает половину 103, пропускает 104 и так далее. Я не могу понять, почему.
Код не полностью функционален и пока не способен анализировать выполнение всех заданий, помещенных в очередь READY, потому что я видел, как это происходит с массивом, и застрял на нем. Есть идеи, что происходит?
Вот код, ввод и вывод.

101 NEW 5 4 0 50
102 NEW 3 3 1 30
103 NEW 4 5 2 100
104 NEW 2 2 3 60
105 NEW 1 6 4 40
106 NEW 3 3 5 70
107 NEW 2 4 6 20
108 NEW 4 5 7 90
109 NEW 5 3 8 50
110 NEW 1 2 9 60
// Create a FIFO CPU Scheduling simulation, Incorporating memory allocation and Deallocation
import java.io.File;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
class Process {
//Class for the processes in the queue
int pid, priority, burst, arrival, size, baseRegister, readyTime;
String processStatus;
//Need to add functionality that differentiates time in vs time started
// Tracks wait time, end time, turnaround, and response time
//Constructor, the only type we'll need
public Process(int pid, String processStatus, int priority, int burst, int arrival, int size) {
this.pid = pid;
this.processStatus = processStatus;
this.priority = priority;
this.burst= burst;
this.arrival = arrival;
this.size = size;
this.baseRegister = -1;
}
//Overwrite print to string method for the sake of printing the queue
public String toString() {
return this.pid + " " + this.processStatus + " " + this.burst + " " + this.arrival + " " + this.baseRegister;
}
//Getters
public int getPid() { return this.pid; }
public int getBurst(){ return this.burst; }
public int getArrival(){ return this.arrival; }
public int getSize() { return this.size; }
public int getBaseRegister() { return this.baseRegister; }
//Setters
public void setBaseRegister(int baseRegister) { this.baseRegister = baseRegister; }
public void setProcessStatus(String s) { this.processStatus = s; }
public void setReadyTime(int n) { this.readyTime = n; }
}
//Add functionality to print out memory array
//Add functionality of memory array
public class Main {
//Method to print memory array
public static void printMemory(String[] arr){
if(arr.length!=256){
System.out.println("Array is not a memory block");
return;
}
for(int i=0; i
Подробнее здесь: https://stackoverflow.com/questions/798 ... -strangely
Мобильная версия