private void closeStateSystem() {
/* Close the History system, if there is one */
+ if (currentEvent == null) {
+ return;
+ }
try {
ss.closeHistory(currentEvent.getTimestamp().getValue());
} catch (TimeRangeException e) {
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
value = TmfStateValue.newValueInt(Attributes.STATUS_INTERRUPTED);
ss.modifyAttribute(ts, value, quark);
+\r
+ /* Change the status of the CPU to interrupted */\r
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);\r
+ value = TmfStateValue.newValueInt(Attributes.CPU_STATUS_INTERRUPTED);\r
+ ss.modifyAttribute(ts, value, quark);\r
}
break;
/* Set the previous process back to running */
setProcessToRunning(ts, currentThreadNode);
+\r
+ /* Set the CPU status back to "busy" or "idle" */\r
+ cpuExitInterrupt(ts, currentCPUNode);\r
}
break;
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
value = TmfStateValue.newValueInt(Attributes.STATUS_INTERRUPTED);
ss.modifyAttribute(ts, value, quark);
+\r
+ /* Change the status of the CPU to interrupted */\r
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);\r
+ value = TmfStateValue.newValueInt(Attributes.CPU_STATUS_INTERRUPTED);\r
+ ss.modifyAttribute(ts, value, quark);\r
}
break;
/* Set the previous process back to running */
setProcessToRunning(ts, currentThreadNode);
+\r
+ /* Set the CPU status back to "busy" or "idle" */\r
+ cpuExitInterrupt(ts, currentCPUNode);\r
}
break;
Integer newCurrentThreadNode = ss.getQuarkRelativeAndAdd(threadsNode, nextTid.toString());
currentThreadNodes.set(eventCpu, newCurrentThreadNode);
+ /*
+ * Set the status of the process that got scheduled out, but
+ * only in the case where that process is currently active.
+ */
+ Integer formerThreadNode = ss.getQuarkRelativeAndAdd(threadsNode, prevTid.toString());
+ quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.EXEC_NAME);
+ value = ss.queryOngoingState(quark);
+ if (!value.isNull()) {
+ quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(Attributes.STATUS_WAIT);
+ ss.modifyAttribute(ts, value, quark);
+ }
+
/* Set the status of the new scheduled process */
setProcessToRunning(ts, newCurrentThreadNode);
- /* Set the status of the process that got scheduled out */
- quark = ss.getQuarkRelativeAndAdd(threadsNode, prevTid.toString(), Attributes.STATUS);
- value = TmfStateValue.newValueInt(Attributes.STATUS_WAIT);
- ss.modifyAttribute(ts, value, quark);
-
/* Set the exec name of the new process */
quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.EXEC_NAME);
value = TmfStateValue.newValueString(nextProcessName);
* the new process (in case we haven't seen this process before)
*/
quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.SYSTEM_CALL);
- if (quark == ss.getNbAttributes()) {
+ if (quark == ss.getNbAttributes()) { /* Did we just add this attribute? */
value = TmfStateValue.nullValue();
ss.modifyAttribute(ts, value, quark);
}
quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
value = TmfStateValue.newValueInt(nextTid);
ss.modifyAttribute(ts, value, quark);
+\r
+ /* Set the status of the CPU itself */\r
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);\r
+ if (nextTid > 0) {\r
+ value = TmfStateValue.newValueInt(Attributes.CPU_STATUS_BUSY);\r
+ } else {\r
+ value = TmfStateValue.newValueInt(Attributes.CPU_STATUS_IDLE);\r
+ }\r
+ ss.modifyAttribute(ts, value, quark);\r
}
break;
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
ss.modifyAttribute(ts, value, quark);
}
+\r
+ /**\r
+ * Similar logic as above, but to set the CPU's status when it's coming out\r
+ * of an interruption.\r
+ * @throws AttributeNotFoundException \r
+ * @throws StateValueTypeException \r
+ * @throws TimeRangeException \r
+ */\r
+ private void cpuExitInterrupt(long ts, int currentCpuNode)\r
+ throws StateValueTypeException, AttributeNotFoundException,\r
+ TimeRangeException {\r
+ int quark;\r
+ ITmfStateValue value;\r
+\r
+ quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.CURRENT_THREAD);\r
+ if (ss.queryOngoingState(quark).unboxInt() > 0) {\r
+ /* There was a process on the CPU */\r
+ value = TmfStateValue.newValueInt(Attributes.CPU_STATUS_BUSY);\r
+ } else {\r
+ /* There was no real process scheduled, CPU was idle */\r
+ value = TmfStateValue.newValueInt(Attributes.CPU_STATUS_IDLE);\r
+ }\r
+ quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);\r
+ ss.modifyAttribute(ts, value, quark);\r
+ }\r
}