add codes for generating multi-core version binary. Also add options -multicore ...
[IRC.git] / Robust / src / Analysis / Scheduling / Schedule.java
1 package Analysis.Scheduling;
2
3 import java.util.Hashtable;
4 import java.util.LinkedList;
5 import java.util.Queue;
6 import java.util.Vector;
7
8 import Analysis.TaskStateAnalysis.FlagState;
9 import IR.TaskDescriptor;
10
11 /** This class holds flag transition diagram(s) can be put on one core.
12  */
13 public class Schedule {
14     private int coreNum;
15     private Vector<TaskDescriptor> tasks;
16     private Hashtable<FlagState, Queue<Integer>> targetCores;
17     private Hashtable<FlagState, FlagState> targetFState;
18     
19     public Schedule(int coreNum) {
20         super();
21         this.coreNum = coreNum;
22         this.tasks = null;
23         this.targetCores = null;
24         this.targetFState = null;
25     }
26
27     public int getCoreNum() {
28         return coreNum;
29     }
30     
31     public Hashtable<FlagState, Queue<Integer>> getTargetCoreTable() {
32         return targetCores;
33     }
34     
35     public Queue<Integer> getTargetCores(FlagState fstate) {
36         if(targetCores == null) {
37             return null;
38         }
39         return targetCores.get(fstate);
40     }
41     
42     public Hashtable<FlagState, FlagState> getTargetFStateTable() {
43         return targetFState;
44     }
45     
46     public FlagState getTargetFState(FlagState fstate) {
47         if(targetFState == null) {
48             return null;
49         }
50         return targetFState.get(fstate);
51     }
52
53     public void addTargetCore(FlagState fstate, Integer targetCore/*, Integer num*/) {
54         if(this.targetCores == null) {
55             this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
56         }
57         if(!this.targetCores.containsKey(fstate)) {
58             this.targetCores.put(fstate, new LinkedList<Integer>());
59         }
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.
63         //}
64     }
65     
66     public void addTargetCore(FlagState fstate, Integer targetCore, FlagState tfstate) {
67         if(this.targetCores == null) {
68             this.targetCores = new Hashtable<FlagState, Queue<Integer>>();
69         }
70         if(!this.targetCores.containsKey(fstate)) {
71             this.targetCores.put(fstate, new LinkedList<Integer>());
72         }
73         //if(!this.targetCores.get(fstate).contains(targetCore)) {
74             this.targetCores.get(fstate).add(targetCore);
75         //}
76         if(this.targetFState == null) {
77             this.targetFState = new Hashtable<FlagState, FlagState>();
78         }
79         //if(!this.targetFState.containsKey(fstate)) {
80             this.targetFState.put(fstate, tfstate);
81         //}
82     }
83
84     public Vector<TaskDescriptor> getTasks() {
85         return tasks;
86     }
87
88     public void addTask(TaskDescriptor task) {
89         if(this.tasks == null) {
90             this.tasks = new Vector<TaskDescriptor>();
91         }
92         if(!this.tasks.contains(task)) {
93             this.tasks.add(task);
94         }
95     } 
96 }