Commit | Line | Data |
---|---|---|
2531b10a CM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 Keba AG | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Christian Mansky - Initial implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis; | |
14 | ||
15 | import org.eclipse.jdt.annotation.Nullable; | |
16 | import org.eclipse.tracecompass.common.core.NonNullUtils; | |
17 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
18 | import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; | |
19 | import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; | |
20 | ||
21 | /** | |
22 | * This aspect finds the priority of the thread running from this event using | |
23 | * the {@link KernelAnalysis}. | |
24 | * | |
25 | * @author Christian Mansky | |
26 | * @since 1.0 | |
27 | */ | |
28 | public final class ThreadPriorityAspect implements ITmfEventAspect { | |
29 | ||
30 | /** The singleton instance */ | |
31 | public static final ThreadPriorityAspect INSTANCE = new ThreadPriorityAspect(); | |
32 | ||
33 | private ThreadPriorityAspect() { | |
34 | } | |
35 | ||
36 | @Override | |
37 | public final String getName() { | |
38 | return NonNullUtils.nullToEmptyString(Messages.AspectName_Prio); | |
39 | } | |
40 | ||
41 | @Override | |
42 | public final String getHelpText() { | |
43 | return NonNullUtils.nullToEmptyString(Messages.AspectHelpText_Prio); | |
44 | } | |
45 | ||
46 | @Override | |
47 | public @Nullable Integer resolve(ITmfEvent event) { | |
48 | KernelAnalysis kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(), KernelAnalysis.class, KernelAnalysis.ID); | |
49 | if (kernelAnalysis == null) { | |
50 | return null; | |
51 | } | |
52 | ||
53 | Integer tid = KernelTidAspect.INSTANCE.resolve(event); | |
54 | if (tid == null) { | |
55 | return null; | |
56 | } | |
57 | ||
58 | Integer prio = KernelThreadInformationProvider.getThreadPrio(kernelAnalysis, tid, event.getTimestamp().getValue()); | |
59 | return prio; | |
60 | } | |
61 | ||
62 | } |