ee095934a458d0692c024d28bd4baa7f5434713c
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / kernel / handlers / PiSetprioHandler.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.trace.IKernelAnalysisEventLayout;
17 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
18 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
19 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
20 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
21 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
22 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
23
24 /**
25 * Set Prio handler
26 */
27 public 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.0328 seconds and 4 git commands to generate.