Ejemplo n.º 1
0
 void destroy() {
   state = State.DESTROYED;
   final MemoryManager memoryManager = MemoryManager.instance();
   try {
     memoryManager.free(pcb.getMemBlock());
   } catch (Exception e) {
     e.printStackTrace();
   }
   setChanged();
   notifyObservers();
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 @Override
 public int compareTo(final Process o) {
   return pcb.getPriority() - o.pcb.getPriority();
 }
Ejemplo n.º 4
0
 public String getPID() {
   return pcb.getPID();
 }