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;
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
}
/* Sub-attributes of the CPU nodes */
public static final String CURRENT_THREAD = "Current_thread";
+ public static final String STATUS = "Status";\r
/* Sub-attributes of the Thread nodes */
public static final String PPID = "PPID";
- public static final String STATUS = "Status";
+ //public static final String STATUS = "Status"\r
public static final String EXEC_NAME = "Exec_name";
public static final String SYSTEM_CALL = "System_call";
public static final String STATISTICS = "Stats";
public static final String EVENT_TYPES = "Event_types";
- /* Process status (note these are *values*, not attribute names) */
+ /* CPU Status (note these are *values*, not attribute names) */\r
+ public static final int CPU_STATUS_IDLE = 0;\r
+ public static final int CPU_STATUS_BUSY = 1;\r
+ public static final int CPU_STATUS_INTERRUPTED = 2;\r
+\r
+ /* Process status */\r
public static final int STATUS_WAIT = 1;
public static final int STATUS_RUN_USERMODE = 2;
public static final int STATUS_RUN_SYSCALL = 3;