[Haskell-cafe] semantics of concurrent program depends on -O level, -f[no-]omit-yields

Sven Panne svenpanne at gmail.com
Thu Nov 29 20:28:24 UTC 2018

Am Do., 29. Nov. 2018 um 19:43 Uhr schrieb Johannes Waldmann <
johannes.waldmann at htwk-leipzig.de>:

> I am surprised by the behaviour of the program below
> (the interesting property is whether it will output "foo").
> Behaviours (plural) actually: it seems to depend
> on optimisation level, on omit-yields,
> and on very small changes in the source code: [...]

IMHO there is nothing very surprising here: You have 2 threads with no
synchronization between them whatsoever, so you get what you deserve:
Undefined behavior. :-) This is the behavior you get in basically all
programming languages/execution environments I know of, *unless* they make
a very strong guarantee about their scheduling behavior (whichis very rare,
for good reasons). Do we have such a guarantee somewhere in the GHC/base
documentation? I don't think so, but if we had, I would be interested to
see a reference to that.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20181129/07999e15/attachment.html>

More information about the Haskell-Cafe mailing list