<div dir="ltr"><div><div>Hi Benjamin,</div><div><br></div><div>I believe that, besides sleep, only the functions rpc and recv also trigger context switches. If you look into the source code of the Ur/Web JavaScript runtime (urweb.js), you will see that there is a boolean variable called maySuspend, which says when context switches are allowed and the only functions that check the value of maySuspend are sl (sleep), rc (rpc) and rc (recv).</div></div><div><br></div><div>Sincerely,</div><div>Saulo Araujo</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 20, 2016 at 5:25 PM, Benjamin Barenblat <span dir="ltr"><<a href="mailto:bbaren@mit.edu" target="_blank">bbaren@mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The threads demo* explains that ‘Ur/Web [client code] uses cooperative<br>
multi-threading, not the more common preemptive multi-threading. Only<br>
one thread runs at a time, and only particular function calls can<br>
trigger context switches. In this example, sleep is the only such<br>
function that appears.’ What other functions can trigger context<br>
switches?<br>
<br>
* <a href="http://impredicative.com/ur/demo/threads.desc.html" rel="noreferrer" target="_blank">http://impredicative.com/ur/<wbr>demo/threads.desc.html</a><br>
<br>
______________________________<wbr>_________________<br>
Ur mailing list<br>
<a href="mailto:Ur@impredicative.com">Ur@impredicative.com</a><br>
<a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer" target="_blank">http://www.impredicative.com/<wbr>cgi-bin/mailman/listinfo/ur</a><br>
</blockquote></div><br></div>