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;
21 public Schedule(int coreNum) {
23 this.coreNum = coreNum;
25 this.targetCores = null;
26 this.targetFState = null;
27 this.ancestorCores = null;
30 public int getCoreNum() {
34 public Hashtable<FlagState, Queue<Integer>> getTargetCoreTable() {
38 public Queue<Integer> getTargetCores(FlagState fstate) {
39 if(targetCores == null) {
42 return targetCores.get(fstate);
45 public Hashtable<FlagState, FlagState> getTargetFStateTable() {
49 public FlagState getTargetFState(FlagState fstate) {
50 if(targetFState == null) {
53 return targetFState.get(fstate);
56 public void addTargetCore(FlagState fstate, Integer targetCore/*, Integer num*/) {
57 if(this.targetCores == null) {
58 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
60 if(!this.targetCores.containsKey(fstate)) {
61 this.targetCores.put(fstate, new LinkedList<Integer>());
63 //if(!this.targetCores.get(fstate).contains(targetCore)) {
64 this.targetCores.get(fstate).add(targetCore); // there may have some duplicate items,
65 // which reflects probabilities.
69 public void addTargetCore(FlagState fstate, Integer targetCore, FlagState tfstate) {
70 if(this.targetCores == null) {
71 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
73 if(!this.targetCores.containsKey(fstate)) {
74 this.targetCores.put(fstate, new LinkedList<Integer>());
76 //if(!this.targetCores.get(fstate).contains(targetCore)) {
77 this.targetCores.get(fstate).add(targetCore);
79 if(this.targetFState == null) {
80 this.targetFState = new Hashtable<FlagState, FlagState>();
82 //if(!this.targetFState.containsKey(fstate)) {
83 this.targetFState.put(fstate, tfstate);
87 public Vector<TaskDescriptor> getTasks() {
91 public void addTask(TaskDescriptor task) {
92 if(this.tasks == null) {
93 this.tasks = new Vector<TaskDescriptor>();
95 if(!this.tasks.contains(task)) {
100 public Vector<Integer> getAncestorCores() {
101 return ancestorCores;
104 public void setAncestorCores(Vector<Integer> ancestorCores) {
105 this.ancestorCores = ancestorCores;
108 public void addAncestorCores(Integer ancestorCore) {
109 if(this.ancestorCores == null) {
110 this.ancestorCores = new Vector<Integer>();
112 if((ancestorCore.intValue() != this.coreNum) && (!this.ancestorCores.contains(ancestorCore))) {
113 this.ancestorCores.addElement(ancestorCore);
117 public int ancestorCoresNum() {
118 if(this.ancestorCores == null) {
121 return this.ancestorCores.size();
124 public Vector<Integer> getChildCores() {
128 public void setChildCores(Vector<Integer> childCores) {
129 this.childCores = childCores;
132 public void addChildCores(Integer childCore) {
133 if(this.childCores == null) {
134 this.childCores = new Vector<Integer>();
136 if((childCore.intValue() != this.coreNum) && (!this.childCores.contains(childCore))) {
137 this.childCores.addElement(childCore);
141 public int childCoresNum() {
142 if(this.childCores == null) {
145 return this.childCores.size();