#5865: threadDelay is disrupted by system clock changes
---------------------------------+------------------------------------------
Reporter: joeyadams | Owner: pcapriotti
Type: bug | Status: patch
Priority: high | Milestone: 7.4.2
Component: Runtime System | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by pcapriotti):
Replying to [comment:18 joeyadams]:
> I don't think the Win32 patch is thread-safe. If two OS threads call
threadDelay simultaneously, it's possible for {{{static}}} variables like
{{{static HsWord64 previous_count}}} to be invalidated by concurrent
updates, since the assignment isn't guaranteed to be atomic (to my
knowledge).
Right, writes are not atomic. So the initialization of the `frequency`
variable is broken, too. The latter can be fixed by moving it to some
global initialization function ('startIOManagerThread`, perhaps?), but I'm
not sure how the `GetTickCount` accumulator can be fixed. I looked into
the `Interlocked*` family of functions, but they are only supported from
XP onwards, which is less then `QueryPerformanceCounter` itself.
Any suggestions?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5865#comment:19>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs