1 package DEOS; 20 21 import gov.nasa.jpf.jvm.Verify; 22 23 24 27 class DEOSThread { 28 Thread thread; boolean running = false; 30 31 boolean isMain = false; 33 boolean isIdle = false; 34 boolean firstTime = true; 35 boolean setDelete = false; 36 boolean setWaitUntilNextPeriod = false; 37 38 public DEOSThread (Thread th) { 39 thread = th; 40 isIdle = thread.isIdle(); 41 isMain = thread.isMain(); 42 43 System.out.println(thread.toString() + " created"); 44 } 45 46 public void run (int tickResult) { 47 DEOS.inc(); 49 50 if (tickResult == Clock.NOTIMECHANGE) { 51 if (Verify.randomBool()) { 52 DEOS.println("No interrupt - Choice 0:"); 54 DEOS.println(thread.toString() + " waiting until next period"); 55 DEOSKernel.waitUntilNextPeriodK(thread); 56 57 } else { 59 DEOS.println("No interrupt - Choice 1:"); 61 DEOS.println(thread.toString() + " deleting"); 62 DEOSKernel.deleteThreadK(thread); } 64 } else { 65 switch (Verify.random(2)) { 66 case 0: 67 68 DEOS.println("Choice 0:"); 70 DEOS.println(thread.toString() + " waiting until next period"); 71 DEOSKernel.waitUntilNextPeriodK(thread); 72 73 break; 75 76 case 2: 77 78 DEOS.println("Choice 2:"); 80 DEOS.println(thread.toString() + " deleting"); 81 DEOSKernel.deleteThreadK(thread); 82 83 break; 85 86 case 1: 87 88 DEOS.println("Choice 1: "); 90 getInterrupted(tickResult); 91 92 break; 93 } 94 } 95 } 96 97 void getInterrupted (int tickResult) { 99 if (tickResult == Clock.SYSTEMINTERRUPT) { 100 DEOS.println(thread.toString() + " interrupted by system tick"); 101 DEOS.thePeriodicClock.resetUsedTime(); 102 Scheduler.handleSystemTickInterrupt(); 103 } else if (tickResult == Clock.TIMEOUT) { 104 DEOS.println(thread.toString() + " interrupted by timer"); 105 Scheduler.handleTimerInterrupt(); 106 } else { 107 DEOS.println(thread.toString() + " waiting for time to pass"); 108 } 109 } 110 } | Popular Tags |