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;
19 public Schedule(int coreNum) {
21 this.coreNum = coreNum;
23 this.targetCores = null;
24 this.targetFState = null;
27 public int getCoreNum() {
31 public Hashtable<FlagState, Queue<Integer>> getTargetCoreTable() {
35 public Queue<Integer> getTargetCores(FlagState fstate) {
36 if(targetCores == null) {
39 return targetCores.get(fstate);
42 public Hashtable<FlagState, FlagState> getTargetFStateTable() {
46 public FlagState getTargetFState(FlagState fstate) {
47 if(targetFState == null) {
50 return targetFState.get(fstate);
53 public void addTargetCore(FlagState fstate, Integer targetCore/*, Integer num*/) {
54 if(this.targetCores == null) {
55 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
57 if(!this.targetCores.containsKey(fstate)) {
58 this.targetCores.put(fstate, new LinkedList<Integer>());
60 //if(!this.targetCores.get(fstate).contains(targetCore)) {
61 this.targetCores.get(fstate).add(targetCore); // there may have some duplicate items,
62 // which reflects probabilities.
66 public void addTargetCore(FlagState fstate, Integer targetCore, FlagState tfstate) {
67 if(this.targetCores == null) {
68 this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
70 if(!this.targetCores.containsKey(fstate)) {
71 this.targetCores.put(fstate, new LinkedList<Integer>());
73 //if(!this.targetCores.get(fstate).contains(targetCore)) {
74 this.targetCores.get(fstate).add(targetCore);
76 if(this.targetFState == null) {
77 this.targetFState = new Hashtable<FlagState, FlagState>();
79 //if(!this.targetFState.containsKey(fstate)) {
80 this.targetFState.put(fstate, tfstate);
84 public Vector<TaskDescriptor> getTasks() {
88 public void addTask(TaskDescriptor task) {
89 if(this.tasks == null) {
90 this.tasks = new Vector<TaskDescriptor>();
92 if(!this.tasks.contains(task)) {