void destroy() { state = State.DESTROYED; final MemoryManager memoryManager = MemoryManager.instance(); try { memoryManager.free(pcb.getMemBlock()); } catch (Exception e) { e.printStackTrace(); } setChanged(); notifyObservers(); }
void run() { state = State.RUN; setChanged(); notifyObservers(); new Thread( () -> { while (state == State.RUN) { if (pcb.getTime() == 0 && !pcb.getPID().equals("DUMMY")) { ProcessManager.instance().destroyProcess(this); } System.out.println( "Process " + pcb.getPID() + " is running, time remaining " + pcb.getTime()); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } pcb.setTime(pcb.getTime() - 1); } }) .start(); }
@Override public int compareTo(final Process o) { return pcb.getPriority() - o.pcb.getPriority(); }
public String getPID() { return pcb.getPID(); }