KernelAnalysis: Use CPUs CoreAttributes to store "Status"
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / kernel / handlers / SoftIrqEntryHandler.java
CommitLineData
c8f45ad2
MK
1/*******************************************************************************
2 * Copyright (c) 2015 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
14
0f7a12d3 15import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
c8f45ad2
MK
16import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
17import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
18import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
19import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
c8f45ad2
MK
20import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
21
22/**
23 * Soft Irq Entry handler
24 */
25public class SoftIrqEntryHandler extends KernelEventHandler {
26
27 /**
28 * Constructor
29 *
30 * @param layout
31 * event layout
32 */
33 public SoftIrqEntryHandler(IKernelAnalysisEventLayout layout) {
34 super(layout);
35 }
36
37 @Override
38 public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
39 Integer cpu = KernelEventHandlerUtils.getCpu(event);
40 if (cpu == null) {
41 return;
42 }
43
44 long timestamp = KernelEventHandlerUtils.getTimestamp(event);
45 Integer softIrqId = ((Long) event.getContent().getField(getLayout().fieldVec()).getValue()).intValue();
46 int currentCPUNode = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
8140841e 47 int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss);
c8f45ad2
MK
48
49 /*
8140841e 50 * Mark this SoftIRQ as active in the resource tree.
c8f45ad2 51 */
19ed6598 52 int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString());
8140841e 53 ITmfStateValue value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
c8f45ad2
MK
54 ss.modifyAttribute(timestamp, value, quark);
55
56 /* Change the status of the running process to interrupted */
c8f45ad2 57 value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
d3cc952f 58 ss.modifyAttribute(timestamp, value, currentThreadNode);
c8f45ad2
MK
59
60 /* Change the status of the CPU to interrupted */
c8f45ad2 61 value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
3ba596bc 62 ss.modifyAttribute(timestamp, value, currentCPUNode);
c8f45ad2
MK
63 }
64}
This page took 0.037588 seconds and 5 git commands to generate.