Skip to content
  • wolfgang's avatar
    [project @ 2003-09-21 22:20:51 by wolfgang] · 85aa72b9
    wolfgang authored
    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)
    85aa72b9