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<FlagState, Queue<Integer>> targetCores;
18 private Hashtable<FlagState, FlagState> targetFState; // only affected by transimit edges
19 private Hashtable<FlagState, Vector<Integer>> allyCores;
20 private Hashtable<TaskDescriptor, Vector<FlagState>> td2fs;
22 public Schedule(int coreNum,
25 this.coreNum = coreNum;
27 this.targetCores = null;
28 this.targetFState = null;
29 this.allyCores = null;
37 public int getCoreNum() {
41 public Hashtable<FlagState, Queue<Integer>> getTargetCoreTable() {
45 public Queue<Integer> getTargetCores(FlagState fstate) {
46 if(targetCores == null) {
49 return targetCores.get(fstate);
52 public Hashtable<FlagState, FlagState> getTargetFStateTable() {
56 public FlagState getTargetFState(FlagState fstate) {
57 if(targetFState == null) {
60 return targetFState.get(fstate);
63 public Hashtable<FlagState, Vector<Integer>> getAllyCoreTable() {
64 return this.allyCores;
67 public Vector<Integer> getAllyCores(FlagState fstate) {
68 if(this.allyCores == null) {
71 return this.allyCores.get(fstate);
74 public Hashtable<TaskDescriptor, Vector<FlagState>> getTd2FsTable() {
78 public Vector<FlagState> getFStates4TD(TaskDescriptor td) {
79 if(this.td2fs == null) {
82 return this.td2fs.get(td);
85 public void addTargetCore(FlagState fstate,
87 if(this.targetCores == null) {
88 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
90 if(!this.targetCores.containsKey(fstate)) {
91 this.targetCores.put(fstate, new LinkedList<Integer>());
93 this.targetCores.get(fstate).add(targetCore); // there may have some duplicate items,
94 // which reflects probabilities.
97 public void addTargetCore(FlagState fstate,
100 if(this.targetCores == null) {
101 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
103 if(!this.targetCores.containsKey(fstate)) {
104 this.targetCores.put(fstate, new LinkedList<Integer>());
106 this.targetCores.get(fstate).add(targetCore);
107 if(this.targetFState == null) {
108 this.targetFState = new Hashtable<FlagState, FlagState>();
110 this.targetFState.put(fstate, tfstate);
113 public void addAllyCore(FlagState fstate,
114 Integer targetCore) {
115 if(this.allyCores == null) {
116 this.allyCores = new Hashtable<FlagState, Vector<Integer>>();
118 if(!this.allyCores.containsKey(fstate)) {
119 this.allyCores.put(fstate, new Vector<Integer>());
121 if((this.coreNum != targetCore.intValue()) && (!this.allyCores.get(fstate).contains(targetCore))) {
122 this.allyCores.get(fstate).add(targetCore); // there may have some duplicate items,
123 // which reflects probabilities.
127 public void addFState4TD(TaskDescriptor td,
129 if(this.td2fs == null) {
130 this.td2fs = new Hashtable<TaskDescriptor, Vector<FlagState>>();
132 if(!this.td2fs.containsKey(td)) {
133 this.td2fs.put(td, new Vector<FlagState>());
135 if(!this.td2fs.get(td).contains(fstate)) {
136 this.td2fs.get(td).add(fstate);
140 public Vector<TaskDescriptor> getTasks() {
144 public void addTask(TaskDescriptor task) {
145 if(this.tasks == null) {
146 this.tasks = new Vector<TaskDescriptor>();
148 if(!this.tasks.contains(task)) {
149 this.tasks.add(task);