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;
18 private Vector<Integer> ancestorCores;
19 private Vector<Integer> childCores;
20 private Hashtable<FlagState, Vector<Integer>> allyCores;
21 private Hashtable<TaskDescriptor, Vector<FlagState>> td2fs;
23 public Schedule(int coreNum) {
25 this.coreNum = coreNum;
27 this.targetCores = null;
28 this.targetFState = null;
29 this.ancestorCores = null;
30 this.allyCores = null;
34 public int getCoreNum() {
38 public Hashtable<FlagState, Queue<Integer>> getTargetCoreTable() {
42 public Queue<Integer> getTargetCores(FlagState fstate) {
43 if(targetCores == null) {
46 return targetCores.get(fstate);
49 public Hashtable<FlagState, FlagState> getTargetFStateTable() {
53 public FlagState getTargetFState(FlagState fstate) {
54 if(targetFState == null) {
57 return targetFState.get(fstate);
60 public Hashtable<FlagState, Vector<Integer>> getAllyCoreTable() {
61 return this.allyCores;
64 public Vector<Integer> getAllyCores(FlagState fstate) {
65 if(this.allyCores == null) {
68 return this.allyCores.get(fstate);
71 public Hashtable<TaskDescriptor, Vector<FlagState>> getTd2FsTable() {
75 public Vector<FlagState> getFStates4TD(TaskDescriptor td) {
76 if(this.td2fs == null) {
79 return this.td2fs.get(td);
82 public void addTargetCore(FlagState fstate, Integer targetCore/*, Integer num*/) {
83 if(this.targetCores == null) {
84 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
86 if(!this.targetCores.containsKey(fstate)) {
87 this.targetCores.put(fstate, new LinkedList<Integer>());
89 //if(!this.targetCores.get(fstate).contains(targetCore)) {
90 this.targetCores.get(fstate).add(targetCore); // there may have some duplicate items,
91 // which reflects probabilities.
95 public void addTargetCore(FlagState fstate, Integer targetCore, FlagState tfstate) {
96 if(this.targetCores == null) {
97 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
99 if(!this.targetCores.containsKey(fstate)) {
100 this.targetCores.put(fstate, new LinkedList<Integer>());
102 //if(!this.targetCores.get(fstate).contains(targetCore)) {
103 this.targetCores.get(fstate).add(targetCore);
105 if(this.targetFState == null) {
106 this.targetFState = new Hashtable<FlagState, FlagState>();
108 //if(!this.targetFState.containsKey(fstate)) {
109 this.targetFState.put(fstate, tfstate);
113 public void addAllyCore(FlagState fstate, Integer targetCore/*, Integer num*/) {
114 if(this.allyCores == null) {
115 this.allyCores = new Hashtable<FlagState, Vector<Integer>>();
117 if(!this.allyCores.containsKey(fstate)) {
118 this.allyCores.put(fstate, new Vector<Integer>());
120 if((this.coreNum != targetCore.intValue()) && (!this.allyCores.get(fstate).contains(targetCore))) {
121 this.allyCores.get(fstate).add(targetCore); // there may have some duplicate items,
122 // which reflects probabilities.
126 public void addFState4TD(TaskDescriptor td, FlagState fstate) {
127 if(this.td2fs == null) {
128 this.td2fs = new Hashtable<TaskDescriptor, Vector<FlagState>>();
130 if(!this.td2fs.containsKey(td)) {
131 this.td2fs.put(td, new Vector<FlagState>());
133 if(!this.td2fs.get(td).contains(fstate)) {
134 this.td2fs.get(td).add(fstate);
138 public Vector<TaskDescriptor> getTasks() {
142 public void addTask(TaskDescriptor task) {
143 if(this.tasks == null) {
144 this.tasks = new Vector<TaskDescriptor>();
146 if(!this.tasks.contains(task)) {
147 this.tasks.add(task);
151 public Vector<Integer> getAncestorCores() {
152 return ancestorCores;
155 public void setAncestorCores(Vector<Integer> ancestorCores) {
156 this.ancestorCores = ancestorCores;
159 public void addAncestorCores(Integer ancestorCore) {
160 if(this.ancestorCores == null) {
161 this.ancestorCores = new Vector<Integer>();
163 if((ancestorCore.intValue() != this.coreNum) && (!this.ancestorCores.contains(ancestorCore))) {
164 this.ancestorCores.addElement(ancestorCore);
168 public int ancestorCoresNum() {
169 if(this.ancestorCores == null) {
172 return this.ancestorCores.size();
175 public Vector<Integer> getChildCores() {
179 public void setChildCores(Vector<Integer> childCores) {
180 this.childCores = childCores;
183 public void addChildCores(Integer childCore) {
184 if(this.childCores == null) {
185 this.childCores = new Vector<Integer>();
187 if((childCore.intValue() != this.coreNum) && (!this.childCores.contains(childCore))) {
188 this.childCores.addElement(childCore);
192 public int childCoresNum() {
193 if(this.childCores == null) {
196 return this.childCores.size();