mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8337199: Add jcmd Thread.vthread_scheduler and Thread.vthread_pollers diagnostic commands
Reviewed-by: dholmes, kevinw
This commit is contained in:
parent
3eb5461578
commit
5c8cb2edcb
11 changed files with 383 additions and 12 deletions
|
@ -36,6 +36,7 @@ import java.util.concurrent.ThreadFactory;
|
|||
import java.util.concurrent.locks.LockSupport;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import jdk.internal.misc.InnocuousThread;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
/**
|
||||
* Polls file descriptors. Virtual threads invoke the poll method to park
|
||||
|
@ -53,6 +54,9 @@ public abstract class Poller {
|
|||
}
|
||||
}
|
||||
|
||||
// the poller or sub-poller thread
|
||||
private @Stable Thread owner;
|
||||
|
||||
// maps file descriptors to parked Thread
|
||||
private final Map<Integer, Thread> map = new ConcurrentHashMap<>();
|
||||
|
||||
|
@ -238,6 +242,7 @@ public abstract class Poller {
|
|||
* descriptor that is polled.
|
||||
*/
|
||||
private void pollerLoop() {
|
||||
owner = Thread.currentThread();
|
||||
try {
|
||||
for (;;) {
|
||||
poll(-1);
|
||||
|
@ -258,6 +263,7 @@ public abstract class Poller {
|
|||
*/
|
||||
private void subPollerLoop(Poller masterPoller) {
|
||||
assert Thread.currentThread().isVirtual();
|
||||
owner = Thread.currentThread();
|
||||
try {
|
||||
int polled = 0;
|
||||
for (;;) {
|
||||
|
@ -282,7 +288,8 @@ public abstract class Poller {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toIdentityString(this) + " [registered = " + registered() + "]";
|
||||
return String.format("%s [registered = %d, owner = %s]",
|
||||
Objects.toIdentityString(this), registered(), owner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -442,4 +449,25 @@ public abstract class Poller {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the master poller or null if there is no master poller.
|
||||
*/
|
||||
public static Poller masterPoller() {
|
||||
return POLLERS.masterPoller();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of read pollers.
|
||||
*/
|
||||
public static List<Poller> readPollers() {
|
||||
return POLLERS.readPollers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of write pollers.
|
||||
*/
|
||||
public static List<Poller> writePollers() {
|
||||
return POLLERS.writePollers();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue