How does forkIO and par interact?
bulat.ziganshin at gmail.com
Sun Dec 20 08:24:05 EST 2009
Sunday, December 20, 2009, 4:17:26 PM, you wrote:
par adds so-called spark to the queue of calculations to proceed. once
RTS has free thread, this thread starts to calculate the spark. it has
no communication with thread that created the spark. when calculation
is completed, its thunk will be updated with result of calculation (as
usual in lazy calculations). so killing originator thread doesn't
affect all the sparks it has created, it only prevents generation of
> How does forkIO (forkOS) and par interact with one another? Here is
> why I ask.
> I have a GUI application that has something like this:
> th <- forkIO (guiCode + longRunningPureSerialCode)
> Later, a user interaction invokes
> killThread th
> and the guiCode plus the longRunningPureSerialCode suspends quite
> nicely. Now I have
> th <- forkIO (guiCode + longRunningPureParallelCode)
> Later a user interaction invokes killThread th again but I have
> observed under 6.10.4 that not all is suspended. From what I have
> observed, I believe that if
> longRunningPureParallelCode = ... 1stPart `par` 2ndPart ...
> the 2ndPart is suspended by killThread th along with the guiCode, and
> the 1stPart happily continues calcualting. (I believe this is correct
> but it could be the other way around.)
> For my little application, having everything suspend would have been
> nice, but that's my app.
> So, under ghc, how is forkIO (forkOS) and par supposed to operationally
> interact with one another?
> - Marcus
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Glasgow-haskell-users