os.linux: Rename the "kernelanalysis" package to just "kernel"
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / kernel / handlers / PiSetprioHandler.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.Attributes;
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;
22import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
23
24/**
25 * Set Prio handler
26 */
27public class PiSetprioHandler extends KernelEventHandler {
28
29 /**
30 * Constructor
31 * @param layout event layout
32 */
33 public PiSetprioHandler(IKernelAnalysisEventLayout layout) {
34 super(layout);
35 }
36
37 @Override
38 public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
39 ITmfEventField content = event.getContent();
40 Integer tid = ((Long) content.getField(getLayout().fieldTid()).getValue()).intValue();
41 Integer prio = ((Long) content.getField(getLayout().fieldNewPrio()).getValue()).intValue();
42
43 Integer updateThreadNode = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeThreads(ss), tid.toString());
44
45 /* Set the current prio for the new process */
46 int quark = ss.getQuarkRelativeAndAdd(updateThreadNode, Attributes.PRIO);
47 ITmfStateValue value = TmfStateValue.newValueInt(prio);
48 ss.modifyAttribute(KernelEventHandlerUtils.getTimestamp(event), value, quark);
49 }
50}
This page took 0.031225 seconds and 5 git commands to generate.