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 {
15 private Vector<TaskDescriptor> tasks;
16 private Hashtable<FlagState, Queue<Integer>> targetCores;
17 private Hashtable<FlagState, FlagState> targetFState; // only affected by transimit edges
18 private Hashtable<FlagState, Vector<Integer>> allyCores;
19 private Hashtable<TaskDescriptor, Vector<FlagState>> td2fs;
21 public Schedule(int coreNum) {
23 this.coreNum = coreNum;
25 this.targetCores = null;
26 this.targetFState = null;
27 this.allyCores = null;
31 public int getCoreNum() {
35 public Hashtable<FlagState, Queue<Integer>> getTargetCoreTable() {
39 public Queue<Integer> getTargetCores(FlagState fstate) {
40 if(targetCores == null) {
43 return targetCores.get(fstate);
46 public Hashtable<FlagState, FlagState> getTargetFStateTable() {
50 public FlagState getTargetFState(FlagState fstate) {
51 if(targetFState == null) {
54 return targetFState.get(fstate);
57 public Hashtable<FlagState, Vector<Integer>> getAllyCoreTable() {
58 return this.allyCores;
61 public Vector<Integer> getAllyCores(FlagState fstate) {
62 if(this.allyCores == null) {
65 return this.allyCores.get(fstate);
68 public Hashtable<TaskDescriptor, Vector<FlagState>> getTd2FsTable() {
72 public Vector<FlagState> getFStates4TD(TaskDescriptor td) {
73 if(this.td2fs == null) {
76 return this.td2fs.get(td);
79 public void addTargetCore(FlagState fstate, Integer targetCore) {
80 if(this.targetCores == null) {
81 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
83 if(!this.targetCores.containsKey(fstate)) {
84 this.targetCores.put(fstate, new LinkedList<Integer>());
86 this.targetCores.get(fstate).add(targetCore); // there may have some duplicate items,
87 // which reflects probabilities.
90 public void addTargetCore(FlagState fstate, Integer targetCore, FlagState tfstate) {
91 if(this.targetCores == null) {
92 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
94 if(!this.targetCores.containsKey(fstate)) {
95 this.targetCores.put(fstate, new LinkedList<Integer>());
97 this.targetCores.get(fstate).add(targetCore);
98 if(this.targetFState == null) {
99 this.targetFState = new Hashtable<FlagState, FlagState>();
101 this.targetFState.put(fstate, tfstate);
104 public void addAllyCore(FlagState fstate, Integer targetCore) {
105 if(this.allyCores == null) {
106 this.allyCores = new Hashtable<FlagState, Vector<Integer>>();
108 if(!this.allyCores.containsKey(fstate)) {
109 this.allyCores.put(fstate, new Vector<Integer>());
111 if((this.coreNum != targetCore.intValue()) && (!this.allyCores.get(fstate).contains(targetCore))) {
112 this.allyCores.get(fstate).add(targetCore); // there may have some duplicate items,
113 // which reflects probabilities.
117 public void addFState4TD(TaskDescriptor td, FlagState fstate) {
118 if(this.td2fs == null) {
119 this.td2fs = new Hashtable<TaskDescriptor, Vector<FlagState>>();
121 if(!this.td2fs.containsKey(td)) {
122 this.td2fs.put(td, new Vector<FlagState>());
124 if(!this.td2fs.get(td).contains(fstate)) {
125 this.td2fs.get(td).add(fstate);
129 public Vector<TaskDescriptor> getTasks() {
133 public void addTask(TaskDescriptor task) {
134 if(this.tasks == null) {
135 this.tasks = new Vector<TaskDescriptor>();
137 if(!this.tasks.contains(task)) {
138 this.tasks.add(task);