Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 package DEOS; 20 21 24 class StartOfPeriodEvent { 25 static StartOfPeriodEvent[] periodicEvents; 27 int itsPeriodId; 28 int itsPassCount; 29 int countDown; 30 int itsPeriodIndex; 31 threadList itsWaitingThreads; 32 StartOfPeriodEvent itsSuccessor; 33 34 private StartOfPeriodEvent (int thePeriodIndex, int thePassCount) { 35 itsPassCount = thePassCount; 36 itsPeriodIndex = thePeriodIndex; 37 itsWaitingThreads = new threadList(); 38 39 countDown = 1; 40 itsPeriodId = 0; 41 itsSuccessor = null; 42 } 43 44 public int currentPeriod () { 45 return itsPeriodId; 46 } 47 48 public static StartOfPeriodEvent eventForPeriodIndex (int i) { 52 return periodicEvents[i]; 53 } 54 55 public static void initialize () { 56 int numPeriods = Registry.numPeriods; 58 59 60 periodicEvents = new StartOfPeriodEvent[numPeriods]; 62 63 int ticksInLastPeriod = 1; 64 65 for (int i = 0; i < numPeriods; i++) { 66 int ticksInThisPeriod = Registry.periodDurationInSystemTicks(i); 67 periodicEvents[i] = new StartOfPeriodEvent(i, 68 ticksInThisPeriod / ticksInLastPeriod); 69 70 if (i > 0) { 71 periodicEvents[i - 1].itsSuccessor = periodicEvents[i]; 72 } 73 74 ticksInLastPeriod = ticksInThisPeriod; 75 } 76 77 } 82 83 public void makeThreadWait (Thread theThread) { 84 itsWaitingThreads.addAtEnd(theThread.startOfPeriodWaitNode); 87 } 88 89 public void pulseEvent (int systemTickCount) { 90 countDown = countDown - 1; 91 92 if (countDown == 0) { 95 itsPeriodId = (itsPeriodId + 1) % 2; 97 98 countDown = itsPassCount; 100 Scheduler.runnableList().mergeList(itsWaitingThreads); 101 102 if (itsSuccessor != null) { 103 itsSuccessor.pulseEvent(systemTickCount); 104 } 105 } 106 } 107 }
| Popular Tags
|