JVMTI resume and suspend for virtual and carrier threads
Serguei Spitsyn
serguei.spitsyn at oracle.com
Wed Sep 4 21:48:43 UTC 2024
Sorry, I’ve just noticed the questions were already answered by Alan and Chris.
Thanks,
Serguei
From: loom-dev <loom-dev-retn at openjdk.org> on behalf of Serguei Spitsyn <serguei.spitsyn at oracle.com>
Date: Wednesday, September 4, 2024 at 2:45 PM
To: Babneet B Singh <sbabneet at ca.ibm.com>, loom-dev at openjdk.org <loom-dev at openjdk.org>
Subject: Re: JVMTI resume and suspend for virtual and carrier threads
Hi Babneet,
Sorry, I’ve overlooked your question on the loom-dev mailing list.
Will try to answer this assuming it is still needed.
>> jvmti->SuspendThread(virtualThread) // Will this also suspend the carrier thread?
Virtual thread can be unmounted. There is no carrier thread in such a case.
If the virtual thread has been mounted then the corresponding carrier thread is being blocked waiting for virtual thread to return the execution control.
>> jvmti->SuspendThread(carrierThread) // Will this also suspend the virtual thread?
No. The virtual thread will continue its execution upon return control to the carrier.
The JavaThread associated with the carrier thread will be blocked/suspended upon return control to carrier thread at virtual thread unmount point.
>> jvmti->ResumeThread(virtualThread) // Will this resume both virtual thread and its carrier thread?
It will resume just virtual thread according to the JVMTI spec.
>> jvmti->ResumeThread(carrierThread) // Will this just resume the carrier thread and virtual thread will stay suspended?
The question itself is incorrect and already has a mistake.
This depends on if any virtual thread has been mounted at this point or not.
If no virtual thread has been currently mounted or mounted virtual thread has not been suspended then the question is invalid.
If there a virtual thread mounted on this carrier thread and it has been suspended then this does has no impact on the suspension of virtual thread.
Summary:
JVMTI Suspend/Resume act on the target thread (virtiual or carrier) only.
Please, let me know if you still have questions.
Thanks,
Serguei
From: loom-dev <loom-dev-retn at openjdk.org> on behalf of Babneet B Singh <sbabneet at ca.ibm.com>
Date: Monday, April 3, 2023 at 9:24 AM
To: loom-dev at openjdk.org <loom-dev at openjdk.org>
Subject: JVMTI resume and suspend for virtual and carrier threads
I would like to request clarification on how JVMTI resume and suspend work for a virtual thread and its associated carrier thread.
Virtual thread runs on a carrier thread. Both are separate Java objects. JVMTI functions can be invoked separately on them. What is the relationship between the state of a virtual and carrier thread when JVMTI suspend and resume functions are invoked on them?
jvmti->SuspendThread(virtualThread) // Will this also suspend the carrier thread?
jvmti->SuspendThread(carrierThread) // Will this also suspend the virtual thread?
jvmti->ResumeThread(virtualThread) // Will this resume both virtual thread and its carrier thread?
jvmti->ResumeThread(carrierThread) // Will this just resume the carrier thread and virtual thread will stay suspended?
Can someone please provide the exact behaviour for the above JVMTI calls?
Regards,
Babneet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20240904/d9753781/attachment.htm>
More information about the loom-dev
mailing list