RFR: 8321270: Virtual Thread.yield consumes parking permit [v2]
Alan Bateman
alanb at openjdk.org
Tue Dec 5 09:51:50 UTC 2023
> When a virtual thread continues after Thread.yield it currently consumes thread's parking permit. This is an oversight, the parking permit should only be consumed when continuing after park.
>
> The changes are straight-forward. The internal "RUNNABLE" state is replaced with UNPARKED and YIELDED state, effectively encoding the previous state. So for the most part, it's just replacing the usages of RUNNABLE. The additional states require refactoring tryGetStackTrace, this is the method that is used for Thread::getStackTrace when the virtual thread is unmounted. It is also changed to not not swallow the REE if the reesubmit fails (tryStackTrace has to resubmit as the task for the thread may run, or the thread unparked, while "suspended" and sampling its stack trace). The changes are a subset of larger changes in the loom repo, future PRs will propose to bring in other changes to get main line up to date.
>
> For testing the existing ThreadAPI has new test cases.
>
> Testing: test1-5. This includes the JVMTI tests as it maps the thread states to JVMTI thread states.
Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
- Fix comment, remove space between case labels and colon
- Merge
- Leave onPinned to another PR
- Initial commit
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/16953/files
- new: https://git.openjdk.org/jdk/pull/16953/files/45c6072a..057c9a57
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=16953&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=16953&range=00-01
Stats: 2035 lines in 49 files changed: 1448 ins; 293 del; 294 mod
Patch: https://git.openjdk.org/jdk/pull/16953.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16953/head:pull/16953
PR: https://git.openjdk.org/jdk/pull/16953
More information about the core-libs-dev
mailing list