Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix virtual thread interrupts #18989

Merged
merged 1 commit into from
Mar 1, 2024
Merged

Fix virtual thread interrupts #18989

merged 1 commit into from
Mar 1, 2024

Conversation

babsingh
Copy link
Contributor

In JDK19+, multiple thread objects can be associated to a J9VMThread:
a virtual thread and its carrier thread.

If a virtual thread is mounted, then the carrier thread is unmounted and
vice-versa. In such cases, J9VMThread's state should not be used to
determine if a thread object is interrupted.

Instead, Thread.interrupted is used to determine if a thread object is
interrupted.

If a mounted thread is suspended, only set Thread.interrupted to TRUE
and do not wake/interrupt the thread. This behaviour is expected in
GetThreadStateMountedTest, which is a test added for virtual threads
in JDK22. These changes are only added for virtual threads in JDK19+.

Related: #18810

@babsingh
Copy link
Contributor Author

@JasonFengJ9 Can you please review this change? It is related to OJDK's Thread impl.

@babsingh
Copy link
Contributor Author

Also, requesting @tajila for a review.

@babsingh babsingh requested a review from tajila February 21, 2024 21:26
@babsingh
Copy link
Contributor Author

babsingh commented Feb 21, 2024

This PR should resolve #18810 which is the last JVMTI issue tagged against JDK22. GetThreadStateMountedTest will be re-enabled and #18810 will be closed after this PR is accepted.

In JDK19+, multiple thread objects can be associated to a J9VMThread:
a virtual thread and its carrier thread.

If a virtual thread is mounted, then the carrier thread is unmounted
and vice-versa. In such cases, J9VMThread's state should not be used
to determine if a thread object is interrupted.

Instead, Thread.interrupted is used to determine if a thread object is
interrupted.

If a mounted thread is suspended, only set Thread.interrupted to TRUE
and do not wake/interrupt the thread. This behaviour is expected in
GetThreadStateMountedTest, which is a test added for virtual threads
in JDK22. These changes are only added for virtual threads in JDK19+.

Related: eclipse-openj9#18810

Signed-off-by: Babneet Singh <[email protected]>
Copy link
Member

@JasonFengJ9 JasonFengJ9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tajila
Copy link
Contributor

tajila commented Feb 29, 2024

jenkins test sanity alinux64 jdk21

@tajila
Copy link
Contributor

tajila commented Feb 29, 2024

jenkins test sanity win jdk8

@babsingh
Copy link
Contributor Author

babsingh commented Feb 29, 2024

The Windows test build failed due to #18998: awk doesn't exist on Windows. These changes are not enabled for JDK8. So, JDK8 compilation is sufficient, and JDK8 testing is not required.

babsingh added a commit to babsingh/aqa-tests that referenced this pull request Feb 29, 2024
@tajila tajila merged commit d3fa3ff into eclipse-openj9:master Mar 1, 2024
5 of 7 checks passed
smlambert pushed a commit to adoptium/aqa-tests that referenced this pull request Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants