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 / IrqEntryHandler.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;
20import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
21import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
22
23/**
24 * Irq Entry Handler
25 */
26public class IrqEntryHandler extends KernelEventHandler {
27
28 /**
29 * Constructor
30 *
31 * @param layout
32 * event layout
33 */
34 public IrqEntryHandler(IKernelAnalysisEventLayout layout) {
35 super(layout);
36 }
37
38 @Override
39 public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
40
41 Integer cpu = KernelEventHandlerUtils.getCpu(event);
42 if (cpu == null) {
43 return;
44 }
45 Integer irqId = ((Long) event.getContent().getField(getLayout().fieldIrq()).getValue()).intValue();
46
47 /*
48 * Mark this IRQ as active in the resource tree. The state value = the
49 * CPU on which this IRQ is sitting
50 */
19ed6598 51 int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeIRQs(cpu, ss), irqId.toString());
c8f45ad2
MK
52
53 ITmfStateValue value = TmfStateValue.newValueInt(cpu.intValue());
54 long timestamp = KernelEventHandlerUtils.getTimestamp(event);
55 ss.modifyAttribute(timestamp, value, quark);
56
57 /* Change the status of the running process to interrupted */
d3cc952f 58 quark = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss);
c8f45ad2
MK
59 value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
60 ss.modifyAttribute(timestamp, value, quark);
61
62 /* Change the status of the CPU to interrupted */
3ba596bc 63 quark = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
c8f45ad2
MK
64 value = StateValues.CPU_STATUS_IRQ_VALUE;
65 ss.modifyAttribute(timestamp, value, quark);
66 }
67
68}
This page took 0.036313 seconds and 5 git commands to generate.