linux: introduce execution contexts in resources view
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / kernel / handlers / SoftIrqEntryHandler.java
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
13 package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
14
15 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
16 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
17 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
18 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
19 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
20 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
21 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
22 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
23
24 /**
25 * Soft Irq Entry handler
26 */
27 public class SoftIrqEntryHandler extends KernelEventHandler {
28
29 /**
30 * Constructor
31 *
32 * @param layout
33 * event layout
34 */
35 public SoftIrqEntryHandler(IKernelAnalysisEventLayout layout) {
36 super(layout);
37 }
38
39 @Override
40 public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
41 Integer cpu = KernelEventHandlerUtils.getCpu(event);
42 if (cpu == null) {
43 return;
44 }
45
46 long timestamp = KernelEventHandlerUtils.getTimestamp(event);
47 Integer softIrqId = ((Long) event.getContent().getField(getLayout().fieldVec()).getValue()).intValue();
48 int currentCPUNode = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
49 int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu,ss);
50
51 /*
52 * Mark this SoftIRQ as active in the resource tree. The state value =
53 * the CPU on which this SoftIRQ is processed
54 */
55 int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString());
56 ITmfStateValue value = TmfStateValue.newValueInt(cpu.intValue());
57 ss.modifyAttribute(timestamp, value, quark);
58
59 /* Change the status of the running process to interrupted */
60 quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
61 value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
62 ss.modifyAttribute(timestamp, value, quark);
63
64 /* Change the status of the CPU to interrupted */
65 quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
66 value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
67 ss.modifyAttribute(timestamp, value, quark);
68 }
69 }
This page took 0.03247 seconds and 5 git commands to generate.