diff --git a/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java b/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java index 5bf0f584d60a..8deaf7832fcf 100644 --- a/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java +++ b/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java @@ -373,7 +373,7 @@ public synchronized void waitUntilCount(long count) { @Test public void testPauseManyThreads() throws ExecutionException, InterruptedException, IOException { - int nThreads = Runtime.getRuntime().availableProcessors() + 2; + int nThreads = Runtime.getRuntime().availableProcessors() + 1; ExecutorService executorService = threadPool(nThreads, vthreads); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Engine.Builder engineBuilder = Engine.newBuilder().allowExperimentalOptions(true).option("engine.SynchronousThreadLocalActionMaxWait", "1").out(outputStream).err(outputStream); @@ -462,7 +462,7 @@ public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable ex Assert.assertFalse(pauseFuture1.isCancelled()); // The one thread executing context1 is now paused /* - * Execute the same code in context2 in availableProcessors + 1 (nThreads - 1) threads. + * Execute the same code in context2 in availableProcessors (nThreads - 1) threads. */ for (int i = 1; i < nThreads; i++) { executorService.submit(() -> { @@ -484,13 +484,13 @@ public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable ex * the synchronous pause thread local action may not reach the synchronization point in * case virtual threads are used and is automatically cancelled. The reason for not * reaching the synchronization point is that when availableProcessors of these threads - * are pinned and then the waiting for the start sync of the pause thread local action - * using LockSupport.parkNanos, the (availableProcessors + 1)-th thread cannot run - * because the parallelism of the default virtual thread scheduler is only - * availableProcessors and none of the "parked" threads, though waiting, can be - * compensated for due to the pinning. Also, the timeout for the pause thread local - * action sync is pretty small (one second) so the cancellation might occur even for - * platform threads in case some unusual slowdown. + * are pinned and waiting for the start sync of the pause thread local action using + * LockSupport.parkNanos (or already paused in case of the already paused context1 + * thread), the (availableProcessors + 1)-th thread cannot run because the parallelism + * of the default virtual thread scheduler is only availableProcessors and none of the + * "parked" threads, though waiting, can be compensated for due to the pinning. Also, + * the timeout for the pause thread local action sync is pretty small (one second) so + * the cancellation might occur even for platform threads in case some unusual slowdown. */ boolean pause2Cancelled = pauseFuture2.isCancelled(); // If context2 pausing is cancelled, new thread in context2 should not be paused even