Import lttng.kernel.core plugins from Scope
[deliverable/tracecompass.git] / lttng / org.lttng.scope.lttng.kernel.core / src / org / lttng / scope / lttng / kernel / core / analysis / os / handlers / internal / PiSetprioHandler.java
CommitLineData
af3275f8
AM
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.lttng.scope.lttng.kernel.core.analysis.os.handlers.internal;
14
15import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
16import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
17import org.lttng.scope.lttng.kernel.core.analysis.os.Attributes;
18import org.lttng.scope.lttng.kernel.core.trace.layout.ILttngKernelEventLayout;
19
20import ca.polymtl.dorsal.libdelorean.ITmfStateSystemBuilder;
21import ca.polymtl.dorsal.libdelorean.exceptions.AttributeNotFoundException;
22import ca.polymtl.dorsal.libdelorean.statevalue.ITmfStateValue;
23import ca.polymtl.dorsal.libdelorean.statevalue.TmfStateValue;
24
25/**
26 * Set Prio handler
27 */
28public class PiSetprioHandler extends KernelEventHandler {
29
30 /**
31 * Constructor
32 * @param layout event layout
33 */
34 public PiSetprioHandler(ILttngKernelEventLayout layout) {
35 super(layout);
36 }
37
38 @Override
39 public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
40 ITmfEventField content = event.getContent();
41 Integer cpu = KernelEventHandlerUtils.getCpu(event);
42 Integer tid = ((Long) content.getField(getLayout().fieldTid()).getValue()).intValue();
43 Integer prio = ((Long) content.getField(getLayout().fieldNewPrio()).getValue()).intValue();
44
45 String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu);
46 if (threadAttributeName == null) {
47 return;
48 }
49
50 Integer updateThreadNode = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeThreads(ss), threadAttributeName);
51
52 /* Set the current prio for the new process */
53 int quark = ss.getQuarkRelativeAndAdd(updateThreadNode, Attributes.PRIO);
54 ITmfStateValue value = TmfStateValue.newValueInt(prio);
55 ss.modifyAttribute(KernelEventHandlerUtils.getTimestamp(event), value, quark);
56 }
57}
This page took 0.025058 seconds and 5 git commands to generate.