Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

rStatus.java

00001 package gov.nasa.arc.ase.jpf;
00002 
00003 import gov.nasa.arc.ase.jpf.jvm.DynamicArea;
00004 import gov.nasa.arc.ase.jpf.jvm.KernelState;
00005 import gov.nasa.arc.ase.jpf.jvm.VirtualMachine;
00006 import gov.nasa.arc.ase.util.Comma;
00007 import gov.nasa.arc.ase.util.Counter;
00008 import gov.nasa.arc.ase.util.Debug;
00009 import gov.nasa.arc.ase.util.kMG;
00010 import java.io.*;
00011 import java.io.IOException;
00012 import java.util.LinkedList;
00013 import java.util.ListIterator;
00014 
00015 public class rStatus {
00016   public int states;
00017   public int transitions;
00018   public int last_transitions;
00019   public long begin_time;
00020   public long last_time;
00021 // ifdef DISTRIBUTED
00022 
00023 
00024 
00025 
00026 //#endif DISTRIBUTED
00027   public ResultInfo results = null;
00028   private boolean isIdle = false;
00029   
00030   private class StatusServer extends Thread {
00031     public void run() {
00032       if(Engine.options.interactive) return;
00033       try {
00034     int t = Engine.options.report_period * 1000;
00035 // ifdef DISTRIBUTED
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 //#endif DISTRIBUTED
00044       while(true) {
00045         Thread.sleep(t, 0);
00046         dump();
00047         tick();
00048       }
00049       } catch(InterruptedException e) {
00050       }
00051     }
00052   }
00053 
00054   private StatusServer ss;
00055 
00056 // ifdef MEMORY_DUMP
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 // ifdef NO_COMPRESSION
00073 
00074 //#else NO_COMPRESSION
00075 
00076 //#endif NO_COMPRESSION
00077 
00078 
00079 //#endif MEMORY_DUMP
00080 
00081   private LinkedList timers = new LinkedList();
00082 
00083   public rStatus() {
00084     begin_time = System.currentTimeMillis();
00085     last_time = 0;
00086     last_transitions = 0;
00087 // ifdef DISTRIBUTED
00088 
00089 
00090 
00091 
00092 
00093 //#endif DISTRIBUTED
00094   }  
00095 // ifdef DISTRIBUTED
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 // ifdef DEBUG_DISTRIBUTED
00108 
00109 //#endif DEBUG_DISTRIBUTED
00110 // ifdef DEBUG
00111 
00112 //#endif DEBUG
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 // ifdef DEBUG_DISTRIBUTED
00122 
00123 //#endif DEBUG_DISTRIBUTED
00124 // ifdef DEBUG
00125 
00126 //#endif DEBUG
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 // ifdef DEBUG_DISTRIBUTED
00139 
00140 //#endif DEBUG_DISTRIBUTED
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 //#endif DISTRIBUTED
00161 
00162   public void decrStates() {
00163     states--;
00164   }  
00165   public void decrTransitions() {
00166     transitions--;
00167   }  
00168   public void dump() {
00169     if (Engine.options.verify) {
00170 // ifdef DISTRIBUTED
00171 
00172 
00173 
00174 
00175 
00176 //#endif DISTRIBUTED
00177       Runtime rt = Runtime.getRuntime();
00178       Runner.used_memory = rt.totalMemory() - rt.freeMemory();
00179       Debug.println(Debug.WARNING, Comma.format(states) + 
00180       " tr " + Comma.format(transitions) + 
00181       " sd " + Comma.format(Runner.max_stack_depth) + 
00182       gov.nasa.arc.ase.jpf.jvm.VirtualMachine.getStatus() + 
00183       " mem " + 
00184       kMG.format(Runner.used_memory) +
00185       " ela " + elapsed());
00186     } else
00187       Debug.println(Debug.WARNING, "States = " + Comma.format(states));
00188   }  
00189   public String elapsed() {
00190     long e = System.currentTimeMillis() - begin_time;
00191     long s = (e / 1000) % 60;
00192     long m = e / 60000;
00193     long spd = 0;
00194     if (e != last_time)
00195       spd = ResultInfo.speed(transitions - last_transitions, e - last_time);
00196     last_time = e;
00197     last_transitions = transitions;
00198 
00199     if (s < 10)
00200       return m + ":0" + s + " spd " + Comma.format(spd) + "t/s";
00201     else
00202       return m + ":" + s + " spd " + Comma.format(spd) + "t/s";
00203   }  
00204   public void generateResults() {
00205     results = new ResultInfo(this);
00206   }  
00207   public int getStates() {
00208     return states;
00209   }  
00210   public int getTransitions() {
00211     return transitions;
00212   }  
00213   public void incrStates(int depth) {
00214     states++;
00215 // ifdef MEMORY_DUMP
00216 
00217 //#endif MEMORY_DUMP
00218   }  
00219   public void incrTransitions(int depth) {
00220     transitions++;
00221 // ifdef MEMORY_DUMP
00222 
00223 //#endif MEMORY_DUMP
00224   }  
00225   public void print(String message) {
00226     long time_end = System.currentTimeMillis();
00227 // ifdef DISTRIBUTED
00228 
00229 //#endif DISTRIBUTED
00230 
00231     if(results == null) generateResults();
00232     results.print(message);
00233 // ifdef DEBUG_DISTRIBUTED
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00242 
00243 
00244 
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00252 //#endif DEBUG_DISTRIBUTED
00253   }  
00254   public void registerTimer(Timer t) {
00255     timers.addLast(t);
00256   }  
00257   public void start() {
00258     ss = new StatusServer();
00259     ss.start();
00260   }  
00261   public void stop() {
00262     ss.interrupt();
00263   }  
00264   public void tick() {
00265     for(ListIterator i = timers.listIterator(); i.hasNext(); ) {
00266       Timer t = (Timer)i.next();
00267 
00268       t.tick();
00269     }
00270   }  
00271 }

Generated at Thu Feb 7 06:54:28 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001