087abb4fa059a427b9e6a2e701237040d2008d14
[deliverable/tracecompass.git] / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / kernelanalysis / ThreadPriorityAspect.java
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 KernelAnalysisModule}.
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 KernelAnalysisModule kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(), KernelAnalysisModule.class, KernelAnalysisModule.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 }
This page took 0.031341 seconds and 4 git commands to generate.