I need to do the planning algorithm fifo
, I'm doing it in Java
but I'm stuck in the part of the processes to be organized, I have two Array
one with the arrival time and the other with the time of rafagaCpu
or service time, but when organizing the arrival time with a Sort
I do not know how to make the Array rafagaCpu
accommodate the new order of arrival time to be more explicit I will show it like this.
1. P1 5 6
2. P2 2 4
3. P3 0 3
4. P4 3 7
Where the first column is the processes, the second, time of arrival and the third is the Rafaga de cpu.
When I apply Sort
the order changes only for the second column
1. P1 0 6
2. P2 2 4
3. P3 3 3
4. P4 5 7
I need the third one to do it too but I do not know how
int tiempoLlegada[] = new int[numeroProcesos];
int rafagaCpu[] = new int[numeroProcesos];
for (int i = 0; i < numeroProcesos; i++) {
tiempoLlegada[i] = Integer.parseInt(JOptionPane.showInputDialog(null,"Tiempo de llegada del proceso "+(i+1)));
for (int j=0;i<numeroProcesos;j++){
rafagaCpu[i]=Integer.parseInt(JOptionPane.showInputDialog(null,"Rafaga de Cpu del proceso "+(i+1)));
}
}
Arrays.sort(tiempoLlegada);