<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        mso-ligatures:none;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:14.0pt">Sorry, I’ve just noticed the questions were already answered by Alan and Chris.<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt">Serguei<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:14.0pt"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">loom-dev <loom-dev-retn@openjdk.org> on behalf of Serguei Spitsyn <serguei.spitsyn@oracle.com><br>
<b>Date: </b>Wednesday, September 4, 2024 at 2:45</span><span style="font-family:"Arial",sans-serif;color:black"> </span><span style="color:black">PM<br>
<b>To: </b>Babneet B Singh <sbabneet@ca.ibm.com>, loom-dev@openjdk.org <loom-dev@openjdk.org><br>
<b>Subject: </b>Re: JVMTI resume and suspend for virtual and carrier threads<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:14.0pt">Hi Babneet,<br>
<br>
Sorry, I’ve overlooked your question on the loom-dev mailing list.<br>
Will try to answer this assuming it is still needed.</span><o:p></o:p></p>
<pre style="background:white"><span style="font-size:12.0pt;color:black">>> jvmti->SuspendThread(virtualThread) // Will this also suspend the carrier thread?</span><o:p></o:p></pre>
<p class="MsoNormal"><span style="font-size:14.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:14.0pt">Virtual thread can be unmounted. There is no carrier thread in such a case.<br>
If the virtual thread has been mounted then the corresponding carrier thread is being blocked waiting for virtual thread to return the execution control.</span><o:p></o:p></p>
<pre style="background:white"><span style="font-size:12.0pt;color:black">>> jvmti->SuspendThread(carrierThread) // Will this also suspend the virtual thread?</span><o:p></o:p></pre>
<pre style="background:white"><span style="font-size:14.0pt;font-family:"Aptos",sans-serif;color:black"><br>No. The virtual thread will continue its execution upon return control to the carrier.<br>The JavaThread associated with the carrier thread will be blocked/suspended upon return control to carrier thread at virtual thread unmount point. <br><br>>> </span><span style="font-size:12.0pt;color:black">jvmti->ResumeThread(virtualThread) // Will this resume both virtual thread and its carrier thread?</span><o:p></o:p></pre>
<pre style="background:white"><span style="font-size:14.0pt;font-family:"Aptos",sans-serif;color:black"><br>It will resume just virtual thread according to the JVMTI spec.<br><br>>> </span><span style="font-size:12.0pt;color:black">jvmti->ResumeThread(carrierThread) // Will this just resume the carrier thread and virtual thread will stay suspended?</span><o:p></o:p></pre>
<pre style="background:white"><span style="font-size:12.0pt;color:black"> </span><o:p></o:p></pre>
<p class="MsoNormal"><span style="font-size:14.0pt">The question itself is incorrect and already has a mistake.<br>
This depends on if any virtual thread has been mounted at this point or not.<br>
If no virtual thread has been currently mounted or mounted virtual thread has not been suspended then the question is invalid.<br>
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.<br>
<br>
Summary:<br>
JVMTI Suspend/Resume act on the target thread (virtiual or carrier) only.<br>
<br>
Please, let me know if you still have questions.<br>
<br>
Thanks,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:14.0pt">Serguei</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:14.0pt"> </span><o:p></o:p></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">loom-dev <loom-dev-retn@openjdk.org> on behalf of Babneet B Singh <sbabneet@ca.ibm.com><br>
<b>Date: </b>Monday, April 3, 2023 at 9:24</span><span style="font-family:"Arial",sans-serif;color:black"> </span><span style="color:black">AM<br>
<b>To: </b>loom-dev@openjdk.org <loom-dev@openjdk.org><br>
<b>Subject: </b>JVMTI resume and suspend for virtual and carrier threads</span><o:p></o:p></p>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black">I would like to request clarification on how JVMTI resume and suspend work for a virtual thread and its associated carrier thread.</span><o:p></o:p></pre>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black"> </span><o:p></o:p></pre>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black">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?</span><o:p></o:p></pre>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black"> </span><o:p></o:p></pre>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black">jvmti->SuspendThread(virtualThread) // Will this also suspend the carrier thread?</span><o:p></o:p></pre>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black">jvmti->SuspendThread(carrierThread) // Will this also suspend the virtual thread?</span><o:p></o:p></pre>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black">jvmti->ResumeThread(virtualThread) // Will this resume both virtual thread and its carrier thread?</span><o:p></o:p></pre>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black">jvmti->ResumeThread(carrierThread) // Will this just resume the carrier thread and virtual thread will stay suspended?</span><o:p></o:p></pre>
</div>
<div>
<pre style="background:white"><span style="font-size:12.0pt;color:black"> </span><o:p></o:p></pre>
</div>
<pre style="background:white"><span style="font-size:12.0pt;color:black">Can someone please provide the exact behaviour for the above JVMTI calls?<br><br>Regards,<br>Babneet</span><o:p></o:p></pre>
<p class="MsoNormal" style="margin-bottom:12.0pt;background:white"><o:p> </o:p></p>
<pre style="margin-bottom:12.0pt;background:white"><span style="color:black"> </span><o:p></o:p></pre>
<p class="MsoNormal" style="background:white"><span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-family:"Calibri",sans-serif;color:black"> </span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>