Fix tabbing.... Please fix your editors so they do tabbing correctly!!! (Spaces...
[IRC.git] / Robust / src / Analysis / Scheduling / Schedule.java
index 8f8241b2c18d0b30a7ae17a77bd44d813f614b0e..bcbf22bf08dc14fae166abf02a679574529ea0d5 100644 (file)
@@ -14,16 +14,18 @@ public class Schedule {
   private int gid;
   private int coreNum;
   private Vector<TaskDescriptor> tasks;
+  private Hashtable<TaskDescriptor, Integer> td2num;
   private Hashtable<FlagState, Queue<Integer>> targetCores;
   private Hashtable<FlagState, FlagState> targetFState;   // only affected by transimit edges
   private Hashtable<FlagState, Vector<Integer>> allyCores;
   private Hashtable<TaskDescriptor, Vector<FlagState>> td2fs;
 
   public Schedule(int coreNum,
-                 int gid) {
+                  int gid) {
     this.gid = gid;
     this.coreNum = coreNum;
     this.tasks = null;
+    this.td2num = null;
     this.targetCores = null;
     this.targetFState = null;
     this.allyCores = null;
@@ -31,7 +33,7 @@ public class Schedule {
   }
 
   public int getGid() {
-      return gid;
+    return gid;
   }
 
   public int getCoreNum() {
@@ -82,8 +84,8 @@ public class Schedule {
     return this.td2fs.get(td);
   }
 
-  public void addTargetCore(FlagState fstate, 
-                           Integer targetCore) {
+  public void addTargetCore(FlagState fstate,
+                            Integer targetCore) {
     if(this.targetCores == null) {
       this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
     }
@@ -94,9 +96,9 @@ public class Schedule {
                                                       // which reflects probabilities.
   }
 
-  public void addTargetCore(FlagState fstate, 
-                           Integer targetCore, 
-                           FlagState tfstate) {
+  public void addTargetCore(FlagState fstate,
+                            Integer targetCore,
+                            FlagState tfstate) {
     if(this.targetCores == null) {
       this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
     }
@@ -110,8 +112,8 @@ public class Schedule {
     this.targetFState.put(fstate, tfstate);
   }
 
-  public void addAllyCore(FlagState fstate, 
-                         Integer targetCore) {
+  public void addAllyCore(FlagState fstate,
+                          Integer targetCore) {
     if(this.allyCores == null) {
       this.allyCores = new Hashtable<FlagState, Vector<Integer>>();
     }
@@ -119,13 +121,12 @@ public class Schedule {
       this.allyCores.put(fstate, new Vector<Integer>());
     }
     if((this.coreNum != targetCore.intValue()) && (!this.allyCores.get(fstate).contains(targetCore))) {
-      this.allyCores.get(fstate).add(targetCore);       // there may have some duplicate items,
-                                                        // which reflects probabilities.
+      this.allyCores.get(fstate).add(targetCore);
     }
   }
 
-  public void addFState4TD(TaskDescriptor td, 
-                          FlagState fstate) {
+  public void addFState4TD(TaskDescriptor td,
+                           FlagState fstate) {
     if(this.td2fs == null) {
       this.td2fs = new Hashtable<TaskDescriptor, Vector<FlagState>>();
     }
@@ -133,7 +134,7 @@ public class Schedule {
       this.td2fs.put(td, new Vector<FlagState>());
     }
     if(!this.td2fs.get(td).contains(fstate)) {
-      this.td2fs.get(td).add(fstate);
+      this.td2fs.get(td).addElement(fstate);
     }
   }
 
@@ -144,9 +145,17 @@ public class Schedule {
   public void addTask(TaskDescriptor task) {
     if(this.tasks == null) {
       this.tasks = new Vector<TaskDescriptor>();
+      this.td2num = new Hashtable<TaskDescriptor, Integer>();
     }
     if(!this.tasks.contains(task)) {
       this.tasks.add(task);
+      this.td2num.put(task, 1);
+    } else {
+      this.td2num.put(task, this.td2num.get(task).intValue()+1);
     }
   }
-}
\ No newline at end of file
+
+  public int getTaskNum(TaskDescriptor task) {
+    return this.td2num.get(task);
+  }
+}