[project @ 2003-09-21 22:20:51 by wolfgang]
authorwolfgang <unknown>
Sun, 21 Sep 2003 22:20:57 +0000 (22:20 +0000)
committerwolfgang <unknown>
Sun, 21 Sep 2003 22:20:57 +0000 (22:20 +0000)
commit85aa72b9dc6803685595936c61f3cab6faab815a
tree7606cd38aade5427ed3c1a936739164dcb7bbfa3
parent6f0dcafbc883c851aaf6d5a7c446ddaaebe23361
[project @ 2003-09-21 22:20:51 by wolfgang]
Bound Threads
=============

Introduce a way to use foreign libraries that rely on thread local state
from multiple threads (mainly affects the threaded RTS).

See the file threads.tex in CVS at haskell-report/ffi/threads.tex
(not entirely finished yet) for a definition of this extension. A less formal
description is also found in the documentation of Control.Concurrent.

The changes mostly affect the THREADED_RTS (./configure --enable-threaded-rts),
except for saving & restoring errno on a per-TSO basis, which is also necessary
for the non-threaded RTS (a bugfix).

Detailed list of changes
------------------------

- errno is saved in the TSO object and restored when necessary:
ghc/includes/TSO.h, ghc/rts/Interpreter.c, ghc/rts/Schedule.c

- rts_mainLazyIO is no longer needed, main is no special case anymore
ghc/includes/RtsAPI.h, ghc/rts/RtsAPI.c, ghc/rts/Main.c, ghc/rts/Weak.c

- passCapability: a new function that releases the capability and "passes"
  it to a specific OS thread:
ghc/rts/Capability.h ghc/rts/Capability.c

- waitThread(), scheduleWaitThread() and schedule() get an optional
  Capability *initialCapability passed as an argument:
ghc/includes/SchedAPI.h, ghc/rts/Schedule.c, ghc/rts/RtsAPI.c

- Bound Thread scheduling (that's what this is all about):
ghc/rts/Schedule.h, ghc/rts/Schedule.c

- new Primop isCurrentThreadBound#:
ghc/compiler/prelude/primops.txt.pp, ghc/includes/PrimOps.h, ghc/rts/PrimOps.hc,
ghc/rts/Schedule.h, ghc/rts/Schedule.c

- a simple function, rtsSupportsBoundThreads, that returns true if THREADED_RTS
  is defined:
ghc/rts/Schedule.h, ghc/rts/Schedule.c

- a new implementation of forkProcess (the old implementation stays in place
  for the non-threaded case). Partially broken; works for the standard
  fork-and-exec case, but not for much else. A proper forkProcess is
  really next to impossible to implement:
ghc/rts/Schedule.c

- Library support for bound threads:
    Control.Concurrent.
      rtsSupportsBoundThreads, isCurrentThreadBound, forkOS,
      runInBoundThread, runInUnboundThread
libraries/base/Control/Concurrent.hs, libraries/base/Makefile,
libraries/base/include/HsBase.h, libraries/base/cbits/forkOS.c (new file)
16 files changed:
ghc/compiler/prelude/primops.txt.pp
ghc/includes/PrimOps.h
ghc/includes/RtsAPI.h
ghc/includes/SchedAPI.h
ghc/includes/TSO.h
ghc/rts/Capability.c
ghc/rts/Capability.h
ghc/rts/Interpreter.c
ghc/rts/Linker.c
ghc/rts/Main.c
ghc/rts/Makefile
ghc/rts/PrimOps.hc
ghc/rts/RtsAPI.c
ghc/rts/Schedule.c
ghc/rts/Schedule.h
ghc/rts/Weak.c