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