<div dir="ltr">so one way to handle no allocation things playing nicely with the scheduler is to compile haskell code with -fno-omit-yields<div><br></div><div>this will generate code which has scheduler yields even in loops which dont allocate</div><div><br></div><div>cheers!</div><div>-Carter</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 19, 2018 at 3:27 PM Viktor Dukhovni <<a href="mailto:ietf-dane@dukhovni.org">ietf-dane@dukhovni.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Nov 19, 2018 at 11:26:17AM -0800, Ryan Reich wrote:<br>
<br>
> I suppose my question concerns the more general question of how to create<br>
> OS-managed threads in GHC.  [...]<br>
> I would have expected there to<br>
> be a corresponding operation in GHC Haskell ("bound threads" seem not to be<br>
> it, as they are still scheduled by the RTS) but it does not appear that<br>
> there is.  Is this because of the need to keep the runtime unified?<br>
> Because it seems strange that we are prevented from operating truly<br>
> independent threads.<br>
<br>
I was just reading:<br>
<br>
    <a href="https://cs.nyu.edu/~mwalfish/classes/14fa/ref/boehm05threads.pdf" rel="noreferrer" target="_blank">https://cs.nyu.edu/~mwalfish/classes/14fa/ref/boehm05threads.pdf</a><br>
<br>
which may offer some insight.  The runtime needs to be able to<br>
provide a consistent memory model to threads.  Just running something<br>
in an OS thread that's managed by the RTS could make that difficult,<br>
and it is not clear how that cooperates with garbage collection.<br>
<br>
But to your point, when adding threads to your example, I find that<br>
the infinite loop then runs concurrently in all the threads, and<br>
the timeout never happens.  While:<br>
<br>
    Replacing:   let x = 0:x in last x<br>
    with:        let ! x = 0 + x in x<br>
<br>
does make timeout work, so it is not entirely obvious which pure<br>
computations can be timed out.<br>
<br>
-- <br>
        Viktor.<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>