1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.lttng
.scope
.lttng
.kernel
.core
.analysis
.os
.handlers
.internal
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
17 import org
.lttng
.scope
.lttng
.kernel
.core
.analysis
.os
.Attributes
;
18 import org
.lttng
.scope
.lttng
.kernel
.core
.trace
.layout
.ILttngKernelEventLayout
;
20 import ca
.polymtl
.dorsal
.libdelorean
.ITmfStateSystemBuilder
;
21 import ca
.polymtl
.dorsal
.libdelorean
.exceptions
.AttributeNotFoundException
;
22 import ca
.polymtl
.dorsal
.libdelorean
.statevalue
.ITmfStateValue
;
23 import ca
.polymtl
.dorsal
.libdelorean
.statevalue
.TmfStateValue
;
28 public class PiSetprioHandler
extends KernelEventHandler
{
32 * @param layout event layout
34 public PiSetprioHandler(ILttngKernelEventLayout layout
) {
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();
45 String threadAttributeName
= Attributes
.buildThreadAttributeName(tid
, cpu
);
46 if (threadAttributeName
== null) {
50 Integer updateThreadNode
= ss
.getQuarkRelativeAndAdd(KernelEventHandlerUtils
.getNodeThreads(ss
), threadAttributeName
);
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
);