1 package Analysis.Scheduling;
3 import java.util.Hashtable;
4 import java.util.LinkedList;
5 import java.util.Queue;
6 import java.util.Vector;
8 import Analysis.TaskStateAnalysis.FlagState;
9 import IR.TaskDescriptor;
11 /** This class holds flag transition diagram(s) can be put on one core.
13 public class Schedule {
16 private Vector<TaskDescriptor> tasks;
17 private Hashtable<TaskDescriptor, Integer> td2num;
18 private Hashtable<FlagState, Queue<Integer>> targetCores;
19 private Hashtable<FlagState, FlagState> targetFState; // only affected by transimit edges
20 private Hashtable<FlagState, Vector<Integer>> allyCores;
21 private Hashtable<TaskDescriptor, Vector<FlagState>> td2fs;
23 public Schedule(int coreNum,
26 this.coreNum = coreNum;
29 this.targetCores = null;
30 this.targetFState = null;
31 this.allyCores = null;
39 public int getCoreNum() {
43 public Hashtable<FlagState, Queue<Integer>> getTargetCoreTable() {
47 public Queue<Integer> getTargetCores(FlagState fstate) {
48 if(targetCores == null) {
51 return targetCores.get(fstate);
54 public Hashtable<FlagState, FlagState> getTargetFStateTable() {
58 public FlagState getTargetFState(FlagState fstate) {
59 if(targetFState == null) {
62 return targetFState.get(fstate);
65 public Hashtable<FlagState, Vector<Integer>> getAllyCoreTable() {
66 return this.allyCores;
69 public Vector<Integer> getAllyCores(FlagState fstate) {
70 if(this.allyCores == null) {
73 return this.allyCores.get(fstate);
76 public Hashtable<TaskDescriptor, Vector<FlagState>> getTd2FsTable() {
80 public Vector<FlagState> getFStates4TD(TaskDescriptor td) {
81 if(this.td2fs == null) {
84 return this.td2fs.get(td);
87 public void addTargetCore(FlagState fstate,
89 if(this.targetCores == null) {
90 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
92 if(!this.targetCores.containsKey(fstate)) {
93 this.targetCores.put(fstate, new LinkedList<Integer>());
95 this.targetCores.get(fstate).add(targetCore); // there may have some duplicate items,
96 // which reflects probabilities.
99 public void addTargetCore(FlagState fstate,
102 if(this.targetCores == null) {
103 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
105 if(!this.targetCores.containsKey(fstate)) {
106 this.targetCores.put(fstate, new LinkedList<Integer>());
108 this.targetCores.get(fstate).add(targetCore);
109 if(this.targetFState == null) {
110 this.targetFState = new Hashtable<FlagState, FlagState>();
112 this.targetFState.put(fstate, tfstate);
115 public void addAllyCore(FlagState fstate,
116 Integer targetCore) {
117 if(this.allyCores == null) {
118 this.allyCores = new Hashtable<FlagState, Vector<Integer>>();
120 if(!this.allyCores.containsKey(fstate)) {
121 this.allyCores.put(fstate, new Vector<Integer>());
123 if((this.coreNum != targetCore.intValue()) && (!this.allyCores.get(fstate).contains(targetCore))) {
124 this.allyCores.get(fstate).add(targetCore);
128 public void addFState4TD(TaskDescriptor td,
130 if(this.td2fs == null) {
131 this.td2fs = new Hashtable<TaskDescriptor, Vector<FlagState>>();
133 if(!this.td2fs.containsKey(td)) {
134 this.td2fs.put(td, new Vector<FlagState>());
136 if(!this.td2fs.get(td).contains(fstate)) {
137 this.td2fs.get(td).addElement(fstate);
141 public Vector<TaskDescriptor> getTasks() {
145 public void addTask(TaskDescriptor task) {
146 if(this.tasks == null) {
147 this.tasks = new Vector<TaskDescriptor>();
148 this.td2num = new Hashtable<TaskDescriptor, Integer>();
150 if(!this.tasks.contains(task)) {
151 this.tasks.add(task);
152 this.td2num.put(task, 1);
154 this.td2num.put(task, this.td2num.get(task).intValue()+1);
158 public int getTaskNum(TaskDescriptor task) {
159 return this.td2num.get(task);