Commit | Line | Data |
---|---|---|
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 | ||
13 | package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers; | |
14 | ||
0f7a12d3 | 15 | import org.eclipse.tracecompass.analysis.os.linux.core.kernel.Attributes; |
c8f45ad2 MK |
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(); | |
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 | } |