import java.util.Vector;
import Analysis.TaskStateAnalysis.FlagState;
-import IR.ClassDescriptor;
import IR.TaskDescriptor;
public class CoreSimulator {
RuntimeSchedule rSchedule;
TaskSimulator rtask;
Hashtable<FlagState, Queue<Integer>> targetCSimulator;
+ Hashtable<FlagState, Vector<Integer>> allyCSimulator;
Hashtable<FlagState, FlagState> targetFState;
int coreNum;
int activeTime;
return targetCSimulator.get(fstate);
}
- public void setTargetCSimulator(
- Hashtable<FlagState, Queue<Integer>> targetCSimulator) {
+ public void setTargetCSimulator(Hashtable<FlagState, Queue<Integer>> targetCSimulator) {
this.targetCSimulator = targetCSimulator;
}
+ public Vector<Integer> getAllyCores(FlagState fstate) {
+ if(allyCSimulator == null) {
+ return null;
+ }
+ return allyCSimulator.get(fstate);
+ }
+
+ public void setAllyCSimulator(Hashtable<FlagState, Vector<Integer>> allyCSimulator) {
+ this.allyCSimulator = allyCSimulator;
+ }
+
public FlagState getTargetFState(FlagState fstate) {
if(targetFState == null) {
return null;
return;
}
for(int i = 0; i < this.tasks.size(); i++) {
- this.tasks.elementAt(i).enquePara(newObj);
+ this.tasks.elementAt(i).enquePara(newObj, null, 0, true);
+ }
+ }
+
+ public void addObject(ObjectSimulator newObj, FlagState fs, int version) {
+ if(this.tasks == null) {
+ return;
+ }
+ for(int i = 0; i < this.tasks.size(); i++) {
+ this.tasks.elementAt(i).enquePara(newObj, fs, version, false);
}
}
Vector<Queue<ObjectSimulator>> paraQueues = this.rtask.getParaQueues();
for(int i = 0; i < paraQueues.size(); i++) {
ObjectSimulator obj = paraQueues.elementAt(i).poll();
+ obj.setHold(false);
boolean remove = false;
if((this.targetFState != null) && (this.targetFState.containsKey(obj.getCurrentFS()))) {
if(transObjs == null) {
transObjs = new Vector<ObjectSimulator>();
}
- transObjs.add(obj);
+ if(!transObjs.contains(obj)) {
+ transObjs.add(obj);
+ }
remove = true;
}
+ // check if this object becoming shared or not
+ Vector<Integer> allycores = this.getAllyCores(obj.getCurrentFS());
+ if(allycores != null) {
+ obj.setShared(true);
+ for(int k = 0; k < allycores.size(); ++k) {
+ Integer allyCore = allycores.elementAt(k);
+ /*if(allyCore == coreNum) {
+ remove = false;
+ } else {*/
+ if(transObjs == null) {
+ transObjs = new Vector<ObjectSimulator>();
+ }
+ if(!transObjs.contains(obj)) {
+ transObjs.add(obj);
+ }
+ remove = false;
+ //}
+ }
+ }
for(int j = 0; j < this.tasks.size(); j++) {
this.tasks.elementAt(j).refreshPara(obj, remove);
}
ClassDescriptor cd;
FlagState currentFS;
boolean changed;
+ boolean shared;
+ boolean hold;
+ int version;
public ObjectSimulator(ClassDescriptor cd, FlagState currentFS) {
super();
this.cd = cd;
this.currentFS = currentFS;
this.changed = true;
+ this.shared = false;
+ this.hold = false;
+ this.version = 0;
}
public void applyEdge(FEdge fedge) {
changed = true;
this.currentFS = currentFS;
}
-
+
+ public boolean isHold() {
+ return hold;
+ }
+
+ public void setHold(boolean hold) {
+ this.hold = hold;
+ }
+
+ public boolean isShared() {
+ return shared;
+ }
+
+ public void setShared(boolean shared) {
+ this.shared = shared;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public void increaseVersion() {
+ this.version++;
+ }
}
\ No newline at end of file
scheduleEdges.remove(se);
// As se has been changed into an internal edge inside a ScheduleNode,
// change the source and target of se from original ScheduleNodes into ClassNodes.
- se.setTarget(se.getTargetCNode());
- se.setSource(se.getSourceCNode());
- se.getTargetCNode().addEdge(se);
+ if(se.getType() == ScheduleEdge.NEWEDGE) {
+ se.setTarget(se.getTargetCNode());
+ se.setSource(se.getSourceCNode());
+ se.getTargetCNode().addEdge(se);
+ }
} else {
// clone the whole ScheduleNode lists starting with se's target
for(int j = 1; j < repeat; j++ ) {
scheduleEdges.removeElement(se);
// As se has been changed into an internal edge inside a ScheduleNode,
// change the source and target of se from original ScheduleNodes into ClassNodes.
- se.setTarget(se.getTargetCNode());
- se.setSource(se.getSourceCNode());
- se.getTargetCNode().addEdge(se);
+ if(se.getType() == ScheduleEdge.NEWEDGE) {
+ se.setTarget(se.getTargetCNode());
+ se.setSource(se.getSourceCNode());
+ se.getTargetCNode().addEdge(se);
+ }
} else {
handleScheduleEdge(se, true);
}
}
break;
}
- /*case ScheduleEdge.ASSOCEDGE: {
- //TODO
- +
- }*/
}
tmpSchedule.addChildCores(targetcore);
if((targetcore.intValue() != j) && (!ancestorCores[targetcore.intValue()].contains((Integer.valueOf(j))))) {
tmpSchedule.addTargetCore(se.getFstate(), j, se.getTargetFState());
break;
}
- /*case ScheduleEdge.ASSOCEDGE: {
- //TODO
- +
- }*/
}
}
scheduling.add(tmpSchedule);
se = new ScheduleEdge(ctarget, "transmit", sse.getFstate(), sse.getType(), gid);//new ScheduleEdge(ctarget, "transmit", sse.getClassDescriptor(), false, gid);
break;
}
- /*case ScheduleEdge.ASSOCEDGE: {
- //TODO
- se = new ScheduleEdge(ctarget, "associate", sse.getFstate(), sse.getType(), gid);//new ScheduleEdge(ctarget, "transmit", sse.getClassDescriptor(), false, gid);
- break;
- }*/
}
se.setSourceCNode(sourcecn2cn.get(sse.getSourceCNode()));
se.setTargetCNode(targetcn2cn.get(sse.getTargetCNode()));
}
break;
}
- /*case ScheduleEdge.ASSOCEDGE: {
- // TODO
- +
- }*/
}
result.removeElement(sEdge.getTarget());
if(ScheduleEdge.NEWEDGE == sEdge.getType()) {
if(ScheduleEdge.TRANSEDGE == se.getType()) {
sn.removeInedge(se);
this.removeEdge(se);
- Iterator it_edges = sn.edges();
- while(it_edges.hasNext()) {
- ScheduleEdge tse = (ScheduleEdge)it_edges.next();
- tse.setSource(this);
- this.edges.addElement(tse);
- }
// merge the split ClassNode of same class
FlagState sfs = se.getFstate();
}
}
+ // redirect external ScheduleEdges to this ScheduleNode
+ // and scn if it is originally from tcn
+ Iterator it_edges = sn.edges();
+ while(it_edges.hasNext()) {
+ ScheduleEdge tse = (ScheduleEdge)it_edges.next();
+ tse.setSource(this);
+ if(tse.getSourceCNode().equals(tcn)) {
+ tse.setSourceCNode(scn);
+ }
+ this.edges.addElement(tse);
+ }
+
targetSEdges = null;
// As all tasks inside one ScheduleNode are executed sequentially,
CoreSimulator cs = this.cores.elementAt(temp.getCoreNum());
cs.deployTasks(temp.getTasks());
cs.setTargetCSimulator(temp.getTargetCoreTable());
+ cs.setAllyCSimulator(temp.getAllyCoreTable());
cs.setTargetFState(temp.getTargetFStateTable());
}
// inject a Startup Object to each core
TransTaskSimulator tmptask = (TransTaskSimulator)task;
// add ADDOBJ task to targetCore
int targetCoreNum = tmptask.getTargetCoreNum();
- ObjectSimulator nobj = tmptask.refreshTask();
- this.cores.elementAt(targetCoreNum).addObject(nobj);
+ ObjectInfo objinfo = tmptask.refreshTask();
+ ObjectSimulator nobj = objinfo.obj;
+ FlagState fs = objinfo.fs;
+ int version = objinfo.version;
+ this.cores.elementAt(targetCoreNum).addObject(nobj, fs, version);
action = new Action(targetCoreNum, Action.ADDOBJ, 1, nobj.getCd());
cp.addAction(action);
if(!tmptask.isFinished()) {
} else {
CoreSimulator cs = task.getCs();
int coreNum = cs.getCoreNum();
- Hashtable<Integer, Queue<ObjectSimulator>> transObjQueues = new Hashtable<Integer, Queue<ObjectSimulator>>();
- if(task.getCurrentRun().getNewObjs() == null) {
- action = new Action(coreNum, Action.TASKFINISH);
- action.setTd(cs.getRtask().getTd());
- } else {
- action = new Action(coreNum, Action.TFWITHOBJ);
- action.setTd(cs.getRtask().getTd());
- Vector<ObjectSimulator> nobjs = task.getCurrentRun().getNewObjs();
- //Schedule schedule = this.scheduling.elementAt(coreNum);
- for(int j = 0; j < nobjs.size(); j++) {
- ObjectSimulator nobj = nobjs.elementAt(j);
- action.addNewObj(nobj.getCd(), Integer.valueOf(1));
- // send the new object to target core according to pre-decide scheduling
- Queue<Integer> cores = cs.getTargetCores(nobj.getCurrentFS());
- if(cores == null) {
- // this obj will reside on this core
- cs.addObject(nobj);
- } else {
- Integer targetCore = cores.poll();
- if(targetCore == coreNum) {
+ if(task.getCurrentRun().getExetype() == 0) {
+ Hashtable<Integer, Queue<ObjectInfo>> transObjQueues = new Hashtable<Integer, Queue<ObjectInfo>>();
+ if(task.getCurrentRun().getNewObjs() == null) {
+ action = new Action(coreNum, Action.TASKFINISH);
+ action.setTd(cs.getRtask().getTd());
+ } else {
+ action = new Action(coreNum, Action.TFWITHOBJ);
+ action.setTd(cs.getRtask().getTd());
+ Vector<ObjectSimulator> nobjs = task.getCurrentRun().getNewObjs();
+ //Schedule schedule = this.scheduling.elementAt(coreNum);
+ for(int j = 0; j < nobjs.size(); j++) {
+ ObjectSimulator nobj = nobjs.elementAt(j);
+ action.addNewObj(nobj.getCd(), Integer.valueOf(1));
+ // send the new object to target core according to pre-decide scheduling
+ Queue<Integer> cores = cs.getTargetCores(nobj.getCurrentFS());
+ if(cores == null) {
// this obj will reside on this core
cs.addObject(nobj);
} else {
- if(!transObjQueues.containsKey(targetCore)) {
- transObjQueues.put(targetCore, new LinkedList<ObjectSimulator>());
+ Integer targetCore = cores.poll();
+ if(targetCore == coreNum) {
+ // this obj will reside on this core
+ cs.addObject(nobj);
+ } else {
+ if(!transObjQueues.containsKey(targetCore)) {
+ transObjQueues.put(targetCore, new LinkedList<ObjectInfo>());
+ }
+ Queue<ObjectInfo> tmpqueue = transObjQueues.get(targetCore);
+ tmpqueue.add(new ObjectInfo(nobj));
+ }
+ // enqueue this core again
+ cores.add(targetCore);
+ }
+ // check if this object becoming shared or not
+ Vector<Integer> allycores = cs.getAllyCores(nobj.getCurrentFS());
+ if(allycores != null) {
+ nobj.setShared(true);
+ for(int k = 0; k < allycores.size(); ++k) {
+ Integer allyCore = allycores.elementAt(k);
+ if(allyCore == coreNum) {
+ cs.addObject(nobj);
+ } else {
+ if(!transObjQueues.containsKey(allyCore)) {
+ transObjQueues.put(allyCore, new LinkedList<ObjectInfo>());
+ }
+ Queue<ObjectInfo> tmpqueue = transObjQueues.get(allyCore);
+ ObjectInfo nobjinfo = new ObjectInfo(nobj);
+ if(!tmpqueue.contains(nobjinfo)) {
+ tmpqueue.add(nobjinfo);
+ }
+ }
}
- Queue<ObjectSimulator> tmpqueue = transObjQueues.get(targetCore);
- tmpqueue.add(nobj);
}
- // enqueue this core again
- cores.add(targetCore);
}
}
- }
- cp.addAction(action);
- Vector<ObjectSimulator> transObjs = cs.finishTask();
- if(transObjs != null) {
- for(int j = 0; j < transObjs.size(); j++) {
- ObjectSimulator tobj = transObjs.elementAt(j);
- // send the object to target core according to pre-decide scheduling
- Queue<Integer> cores = cs.getTargetCores(tobj.getCurrentFS());
- tobj.setCurrentFS(cs.getTargetFState(tobj.getCurrentFS()));
- if(cores == null) {
- // this obj will reside on this core
- cs.addObject(tobj);
- } else {
- Integer targetCore = cores.peek();
- if(targetCore == coreNum) {
+ cp.addAction(action);
+ Vector<ObjectSimulator> transObjs = cs.finishTask();
+ if(transObjs != null) {
+ for(int j = 0; j < transObjs.size(); j++) {
+ ObjectSimulator tobj = transObjs.elementAt(j);
+ // send the object to target core according to pre-decide scheduling
+ Queue<Integer> cores = cs.getTargetCores(tobj.getCurrentFS());
+ tobj.setCurrentFS(cs.getTargetFState(tobj.getCurrentFS()));
+ if(cores == null) {
// this obj will reside on this core
cs.addObject(tobj);
} else {
- if(!transObjQueues.containsKey(targetCore)) {
- transObjQueues.put(targetCore, new LinkedList<ObjectSimulator>());
+ Integer targetCore = cores.peek();
+ if(targetCore == coreNum) {
+ // this obj will reside on this core
+ cs.addObject(tobj);
+ } else {
+ if(!transObjQueues.containsKey(targetCore)) {
+ transObjQueues.put(targetCore, new LinkedList<ObjectInfo>());
+ }
+ Queue<ObjectInfo> tmpqueue = transObjQueues.get(targetCore);
+ tmpqueue.add(new ObjectInfo(tobj));
+ }
+ }
+ // check if this object becoming shared or not
+ Vector<Integer> allycores = cs.getAllyCores(tobj.getCurrentFS());
+ if(allycores != null) {
+ tobj.setShared(true);
+ for(int k = 0; k < allycores.size(); ++k) {
+ Integer allyCore = allycores.elementAt(k);
+ if(allyCore == coreNum) {
+ cs.addObject(tobj);
+ } else {
+ if(!transObjQueues.containsKey(allyCore)) {
+ transObjQueues.put(allyCore, new LinkedList<ObjectInfo>());
+ }
+ Queue<ObjectInfo> tmpqueue = transObjQueues.get(allyCore);
+ ObjectInfo nobjinfo = new ObjectInfo(tobj);
+ if(!tmpqueue.contains(nobjinfo)) {
+ tmpqueue.add(nobjinfo);
+ }
+ }
}
- Queue<ObjectSimulator> tmpqueue = transObjQueues.get(targetCore);
- tmpqueue.add(tobj);
}
}
}
- }
- // add 'transport' tasks
- Iterator it_entries = transObjQueues.entrySet().iterator();
- while(it_entries.hasNext()) {
- Entry<Integer, Queue<ObjectSimulator>> tmpentry = (Entry<Integer, Queue<ObjectSimulator>>)it_entries.next();
- Integer tmpCoreNum = tmpentry.getKey();
- Queue<ObjectSimulator> nobjs = tmpentry.getValue();
- TransTaskSimulator tmptask = new TransTaskSimulator(cs, tmpCoreNum, nobjs);
- this.tasks.add(tmptask);
- }
- // Choose a new task for this core
- TaskSimulator newTask = cs.process();
- if(newTask != null) {
- this.tasks.add(newTask);
- // add a TASKSTART action into this checkpoint
- action = new Action(coreNum, Action.TASKSTART);
+ // add 'transport' tasks
+ Iterator it_entries = transObjQueues.entrySet().iterator();
+ while(it_entries.hasNext()) {
+ Entry<Integer, Queue<ObjectInfo>> tmpentry = (Entry<Integer, Queue<ObjectInfo>>)it_entries.next();
+ Integer tmpCoreNum = tmpentry.getKey();
+ Queue<ObjectInfo> nobjs = tmpentry.getValue();
+ TransTaskSimulator tmptask = new TransTaskSimulator(cs, tmpCoreNum, nobjs);
+ this.tasks.add(tmptask);
+ }
+ // Choose a new task for this core
+ TaskSimulator newTask = cs.process();
+ if(newTask != null) {
+ this.tasks.add(newTask);
+ // add a TASKSTART action into this checkpoint
+ action = new Action(coreNum, Action.TASKSTART);
+ action.setTd(cs.getRtask().getTd());
+ cp.addAction(action);
+ }
+ } else if (task.getCurrentRun().getExetype() == 1) {
+ action = new Action(coreNum, Action.TASKABORT);
+ action.setTd(cs.getRtask().getTd());
+ cp.addAction(action);
+ } else if (task.getCurrentRun().getExetype() == 2) {
+ action = new Action(coreNum, Action.TASKREMOVE);
action.setTd(cs.getRtask().getTd());
cp.addAction(action);
}
public static final int TASKFINISH = 1;
public static final int TFWITHOBJ = 2;
public static final int TASKSTART = 3;
+ public static final int TASKABORT = 4;
+ public static final int TASKREMOVE = 5;
private int coreNum;
private int type;
isTaskFinish[cNum] = false;
break;
}
+ case Action.TASKABORT: {
+ if(!isfirst) {
+ tmpLabel.append("\\n");
+ }
+ tmpLabel.append("<" + taction.getTd().getSymbol() + ">aborts;");
+ if(!(lastTaskNodes[cNum].equals("first")) &&
+ !(lastTaskNodes[cNum].equals(tmpTaskNode))) {
+ output.print("\t");
+ output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode);
+ lastTaskNodes[cNum] = tmpTaskNode;
+ isTaskFinish[cNum] = true;
+ } else {
+ throw new Exception("Error: unexpected task aborts");
+ }
+ break;
+ }
+ case Action.TASKREMOVE: {
+ if(!isfirst) {
+ tmpLabel.append("\\n");
+ }
+ tmpLabel.append("<" + taction.getTd().getSymbol() + ">removes;");
+ if(!(lastTaskNodes[cNum].equals("first")) &&
+ !(lastTaskNodes[cNum].equals(tmpTaskNode))) {
+ output.print("\t");
+ output.println(lastTaskNodes[cNum] + "->" + tmpTaskNode);
+ lastTaskNodes[cNum] = tmpTaskNode;
+ isTaskFinish[cNum] = true;
+ } else {
+ throw new Exception("Error: unexpected task remove");
+ }
+ break;
+ }
}
}
Enumeration<String> keys = tmpTaskNodes.keys();
package Analysis.Scheduling;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
public class TaskSimulator {
TaskDescriptor td;
Vector<Queue<ObjectSimulator>> paraQueues;
+ Hashtable<ObjectSimulator, Integer> objVersionTbl;
ExeResult currentRun;
CoreSimulator cs;
boolean finish;
public class ExeResult {
int finishTime;
Vector<ObjectSimulator> newObjs;
+ int exetype; // 0--normal executing
+ // 1--abort due to fail on grabbing locks
+ // 2--out of date task
public ExeResult() {
finishTime = 0;
this.newObjs.add(newObj);
}
-
+
+ public int getExetype() {
+ return exetype;
+ }
+
+ public void setExetype(int exetype) {
+ this.exetype = exetype;
+ }
}
public TaskSimulator(TaskDescriptor td, CoreSimulator cs) {
super();
this.td = td;
this.paraQueues = null;
+ this.objVersionTbl = null;
this.currentRun = null;
this.cs = cs;
this.finish = true;
public Vector<Queue<ObjectSimulator>> getParaQueues() {
return paraQueues;
}
+
+ public Hashtable<ObjectSimulator, Integer> getObjVersionTbl() {
+ return objVersionTbl;
+ }
+
+ public int getObjVersion(ObjectSimulator os) {
+ return this.objVersionTbl.get(os).intValue();
+ }
- public void enquePara(ObjectSimulator obj) {
+ public void enquePara(ObjectSimulator obj, FlagState fs, int version, boolean inherent) {
ClassDescriptor cd = obj.getCd();
int paraNum = td.numParameters();
for(int i = 0; i < paraNum; i++) {
if(cd.equals(para.getType().getClassDesc())) {
// check if the status is right
FlagExpressionNode fen = td.getFlag(para);
- if(SchedulingUtil.isTaskTrigger_flag(fen, obj.getCurrentFS())) {
+ FlagState cfs = fs;
+ if(inherent) {
+ cfs = obj.getCurrentFS();
+ }
+ if(SchedulingUtil.isTaskTrigger_flag(fen, cfs)) {
if(this.paraQueues == null) {
this.paraQueues = new Vector<Queue<ObjectSimulator>>();
for(int j = 0; j < paraNum; j++) {
if(this.paraQueues.elementAt(i) == null) {
this.paraQueues.setElementAt(new LinkedList<ObjectSimulator>(), i);
}
- this.paraQueues.elementAt(i).add(obj);
+ if(this.objVersionTbl == null) {
+ this.objVersionTbl = new Hashtable<ObjectSimulator, Integer>();
+ }
+ if(!this.paraQueues.elementAt(i).contains(obj)) {
+ this.paraQueues.elementAt(i).add(obj);
+ if(inherent) {
+ this.objVersionTbl.put(obj, obj.getVersion());
+ } else {
+ this.objVersionTbl.put(obj, version);
+ }
+ }
}
}
}
if(remove) {
if((this.paraQueues != null) &&
(this.paraQueues.elementAt(i) != null) &&
- (this.paraQueues.elementAt(i).contains(obj))){
+ (this.paraQueues.elementAt(i).contains(obj))) {
this.paraQueues.elementAt(i).remove(obj);
+ this.objVersionTbl.remove(obj);
}
} else {
// check if the status is right
this.paraQueues.setElementAt(new LinkedList<ObjectSimulator>(), i);
}
this.paraQueues.elementAt(i).add(obj);
+ if(this.objVersionTbl == null) {
+ this.objVersionTbl = new Hashtable<ObjectSimulator, Integer>();
+ }
+ this.objVersionTbl.put(obj, obj.getVersion());
} else {
if((this.paraQueues != null) &&
(this.paraQueues.elementAt(i) != null) &&
(this.paraQueues.elementAt(i).contains(obj))){
this.paraQueues.elementAt(i).remove(obj);
+ this.objVersionTbl.remove(obj);
}
}
}
// 1.the result, i.e. the result FlagState reached by each parameter.
// 2.the finish time
// 3.any new objects
+
+ // First check if all the parameters are still available.
+ // For shared objects, need to first grab the lock and also check if the version is right
for(int i = 0; i < paraQueues.size(); i++) {
ObjectSimulator tpara = paraQueues.elementAt(i).peek();
+ if(tpara.isShared()) {
+ if(tpara.isHold()) {
+ // shared object held by other tasks
+ finishTime = 1; // TODO currenly assume the effort on requesting locks are only 1
+ this.currentRun.setFinishTime(finishTime);
+ this.currentRun.setExetype(1);
+ paraQueues.elementAt(i).poll();
+ paraQueues.elementAt(i).add(tpara);
+ for(int j = 0; j < i; ++j) {
+ tpara = this.paraQueues.elementAt(j).poll();
+ if(tpara.isShared() && tpara.isHold()) {
+ tpara.setHold(false);
+ }
+ this.paraQueues.elementAt(j).add(tpara);
+ }
+ return;
+ } else if (tpara.getVersion() != this.objVersionTbl.get(tpara)) {
+ // shared object has been updated and no longer fitted to this task
+ finishTime = 1; // TODO currenly assume the effort on requesting locks are only 1
+ this.currentRun.setFinishTime(finishTime);
+ this.currentRun.setExetype(2);
+ paraQueues.elementAt(i).poll();
+ // remove this object from the remaining parameter queues
+ for(int j = i + 1; j < paraQueues.size(); j++) {
+ paraQueues.elementAt(j).remove(tpara);
+ }
+ for(int j = 0; j < i; ++j) {
+ tpara = this.paraQueues.elementAt(j).poll();
+ if(tpara.isShared() && tpara.isHold()) {
+ tpara.setHold(false);
+ }
+ this.paraQueues.elementAt(j).add(tpara);
+ }
+ return;
+ } else {
+ tpara.setHold(true);
+ }
+ }
// remove this object from the remaining parameter queues
for(int j = i + 1; j < paraQueues.size(); j++) {
paraQueues.elementAt(j).remove(tpara);
}
+ }
+ for(int i = 0; i < paraQueues.size(); i++) {
+ ObjectSimulator tpara = paraQueues.elementAt(i).peek();
+
FlagState tfstate = tpara.getCurrentFS();
FEdge toexecute = tfstate.process(td);
finishTime += toexecute.getExeTime();
//FlagState tFState = (FlagState)toexecute.getTarget();
//tpara.setCurrentFS(tFState);
tpara.applyEdge(toexecute);
+ tpara.increaseVersion();
}
finishTime /= paraQueues.size();
this.currentRun.setFinishTime(finishTime);
+ this.currentRun.setExetype(0);
}
public void updateFinishTime(int time) {
\r
public class TransTaskSimulator extends TaskSimulator {\r
private int targetCoreNum;\r
- private Queue<ObjectSimulator> newObjs;\r
+ private Queue<ObjectInfo> newObjs;\r
\r
- public TransTaskSimulator(CoreSimulator cs, int targetCoreNum, Queue<ObjectSimulator> nobjs) {\r
+ public TransTaskSimulator(CoreSimulator cs, int targetCoreNum, Queue<ObjectInfo> nobjs) {\r
super(null, cs);\r
this.targetCoreNum = targetCoreNum;\r
this.newObjs = nobjs;\r
this.currentRun = new ExeResult();\r
}\r
\r
- this.currentRun.finishTime = 1 * sizeof(this.newObjs.peek().getCd());\r
+ this.currentRun.finishTime = 1 * sizeof(this.newObjs.peek().obj.getCd());\r
}\r
\r
- public ObjectSimulator refreshTask() {\r
+ public ObjectInfo refreshTask() {\r
return this.newObjs.poll();\r
}\r
\r
scheduleAnalysis.schedule();
//simulate these schedulings
- //ScheduleSimulator scheduleSimulator = new ScheduleSimulator(scheduleAnalysis.getCoreNum(), state, ta);
+ ScheduleSimulator scheduleSimulator = new ScheduleSimulator(scheduleAnalysis.getCoreNum(), state, ta);
Iterator it_scheduling = scheduleAnalysis.getSchedulingsIter();
- /*int index = 0;
+ int index = 0;
Vector<Integer> selectedScheduling = new Vector<Integer>();
int processTime = Integer.MAX_VALUE;
while(it_scheduling.hasNext()) {
for(int i = 0; i < selectedScheduling.size(); i++) {
System.out.print(selectedScheduling.elementAt(i) + ", ");
}
- System.out.println();*/
+ System.out.println();
/*ScheduleSimulator scheduleSimulator = new ScheduleSimulator(4, state, ta);
Vector<Schedule> scheduling = new Vector<Schedule>();