os.linux: Add per cpu thread 0 modeling
[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();
8a0bbebf 40 Integer cpu = KernelEventHandlerUtils.getCpu(event);
c8f45ad2
MK
41 Integer tid = ((Long) content.getField(getLayout().fieldTid()).getValue()).intValue();
42 Integer prio = ((Long) content.getField(getLayout().fieldNewPrio()).getValue()).intValue();
43
8a0bbebf
MJ
44 String threadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(tid, cpu);
45 if (threadAttributeName == null) {
46 return;
47 }
48
49 Integer updateThreadNode = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeThreads(ss), threadAttributeName);
c8f45ad2
MK
50
51 /* Set the current prio for the new process */
52 int quark = ss.getQuarkRelativeAndAdd(updateThreadNode, Attributes.PRIO);
53 ITmfStateValue value = TmfStateValue.newValueInt(prio);
54 ss.modifyAttribute(KernelEventHandlerUtils.getTimestamp(event), value, quark);
55 }
56}
This page took 0.030085 seconds and 5 git commands to generate.