package org.eclipse.tracecompass.analysis.os.linux.core.kernel;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
import org.eclipse.tracecompass.analysis.os.linux.core.tid.TidAnalysisModule;
/** The singleton instance */
public static final KernelTidAspect INSTANCE = new KernelTidAspect();
+ private static final IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
+
private KernelTidAspect() {
}
@Override
public @Nullable Integer resolve(ITmfEvent event) {
+ try {
+ return resolve(event, false, NULL_MONITOR);
+ } catch (InterruptedException e) {
+ /* Should not happen since there is nothing to interrupt */
+ return null;
+ }
+ }
+
+ @Override
+ public @Nullable Integer resolve(@NonNull ITmfEvent event, boolean block, final IProgressMonitor monitor) throws InterruptedException {
/* Find the CPU this event is run on */
Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(),
TmfCpuAspect.class, event);
if (analysis == null) {
return null;
}
- return analysis.getThreadOnCpuAtTime(cpu, event.getTimestamp().toNanos());
+ long ts = event.getTimestamp().toNanos();
+ while (block && !analysis.isQueryable(ts) && !monitor.isCanceled()) {
+ Thread.sleep(100);
+ }
+ return analysis.getThreadOnCpuAtTime(cpu, ts);
}
}
import java.util.function.Function;
import java.util.stream.Collectors;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelTidAspect;
private final Map<Integer, SystemCall.InitialInfo> fOngoingSystemCalls = new HashMap<>();
private @Nullable IKernelAnalysisEventLayout fLayout;
+ private final IProgressMonitor fMonitor = new NullProgressMonitor();
public SyscallLatencyAnalysisRequest(ISegmentStore<ISegment> syscalls) {
super(syscalls);
eventName.startsWith(layout.eventCompatSyscallEntryPrefix())) {
/* This is a system call entry event */
- Integer tid = KernelTidAspect.INSTANCE.resolve(event);
+ Integer tid;
+ try {
+ tid = KernelTidAspect.INSTANCE.resolve(event, true, fMonitor);
+ } catch (InterruptedException e) {
+ return;
+ }
if (tid == null) {
// no information on this event/trace ?
return;
} else if (eventName.startsWith(layout.eventSyscallExitPrefix())) {
/* This is a system call exit event */
- Integer tid = KernelTidAspect.INSTANCE.resolve(event);
+ Integer tid;
+ try {
+ tid = KernelTidAspect.INSTANCE.resolve(event, true, fMonitor);
+ } catch (InterruptedException e) {
+ return;
+ }
if (tid == null) {
return;
}
@Override
public void handleCompleted() {
fOngoingSystemCalls.clear();
+ super.handleCompleted();
+ }
+
+ @Override
+ public void handleCancel() {
+ fMonitor.setCanceled(true);
+ super.handleCancel();
}
}