This project is mirrored from https://gitlab.haskell.org/ghc/ghc.git. Pull mirroring failed .
Repository mirroring has been paused due to too many failed attempts. It can be resumed by a project maintainer.
Last successful update .
  1. 15 Mar, 2006 1 commit
    • Simon Marlow's avatar
      Improvements to shutting down of the runtime · 5638488b
      Simon Marlow authored
      Yet another attempt at shutdown & interruption.  This one appears to
      work better; ^C is more responsive in multi threaded / SMP, and I
      fixed one case where the runtime wasn't responding to ^C at all.
      5638488b
  2. 16 Jan, 2006 1 commit
  3. 30 Nov, 2005 1 commit
  4. 21 Oct, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-10-21 14:02:17 by simonmar] · 03a9ff01
      simonmar authored
      Big re-hash of the threaded/SMP runtime
      
      This is a significant reworking of the threaded and SMP parts of
      the runtime.  There are two overall goals here:
      
        - To push down the scheduler lock, reducing contention and allowing
          more parts of the system to run without locks.  In particular,
          the scheduler does not require a lock any more in the common case.
      
        - To improve affinity, so that running Haskell threads stick to the
          same OS threads as much as possible.
      
      At this point we have the basic structure working, but there are some
      pieces missing.  I believe it's reasonably stable - the important
      parts of the testsuite pass in all the (normal,threaded,SMP) ways.
      
      In more detail:
      
        - Each capability now has a run queue, instead of one global run
          queue.  The Capability and Task APIs have been completely
          rewritten; see Capability.h and Task.h for the details.
      
        - Each capability has its own pool of worker Tasks.  Hence, Haskell
          threads on a Capability's run queue will run on the same worker
          Task(s).  As long as the OS is doing something reasonable, this
          should mean they usually stick to the same CPU.  Another way to
          look at this is that we're assuming each Capability is associated
          with a fixed CPU.
      
        - What used to be StgMainThread is now part of the Task structure.
          Every OS thread in the runtime has an associated Task, and it
          can ask for its current Task at any time with myTask().
      
        - removed RTS_SUPPORTS_THREADS symbol, use THREADED_RTS instead
          (it is now defined for SMP too).
      
        - The RtsAPI has had to change; we must explicitly pass a Capability
          around now.  The previous interface assumed some global state.
          SchedAPI has also changed a lot.
      
        - The OSThreads API now supports thread-local storage, used to
          implement myTask(), although it could be done more efficiently
          using gcc's __thread extension when available.
      
        - I've moved some POSIX-specific stuff into the posix subdirectory,
          moving in the direction of separating out platform-specific
          implementations.
      
        - lots of lock-debugging and assertions in the runtime.  In particular,
          when DEBUG is on, we catch multiple ACQUIRE_LOCK()s, and there is
          also an ASSERT_LOCK_HELD() call.
      
      What's missing so far:
      
        - I have almost certainly broken the Win32 build, will fix soon.
      
        - any kind of thread migration or load balancing.  This is high up
          the agenda, though.
      
        - various performance tweaks to do
      
        - throwTo and forkProcess still do not work in SMP mode
      03a9ff01
  5. 07 Apr, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-04-07 14:33:30 by simonmar] · 5a148f04
      simonmar authored
      Support handling signals in the threaded RTS by passing the signal
      number down the pipe to the IO manager.  This avoids needing
      synchronisation in the signal handler.
      
      Signals should now work with -threaded.  Since this is a bugfix, I'll
      merge the changes into the 6.4 branch.
      5a148f04
  6. 31 Mar, 2005 1 commit
  7. 14 Oct, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-10-14 14:58:37 by simonmar] · bb01a96b
      simonmar authored
      Threaded RTS improvements:
      
       - Unix only: implement waitRead#, waitWrite# and delay# in Haskell,
         by having a single Haskell thread (the IO manager) performing a blocking
         select() operation.  Threads communicate with the IO manager
         via channels.  This is faster than doing the select() in the RTS,
         because we only restart the select() when a new request arrives,
         rather than each time around the scheduler.
      
         On Windows we just make blocking IO calls, we don't have a fancy IO
         manager (yet).
      
       - Simplify the scheduler for the threaded RTS, now that we don't have
         to wait for IO in the scheduler loop.
      
       - Remove detectBlackHoles(), which isn't used now (not sure how long
         this has been unused for... perhaps it was needed back when main threads
         used to be GC roots, so we had to check for blackholes manually rather
         than relying on the GC.)
      
      Signals aren't quite right in the threaded RTS.  In fact, they're
      slightly worse than before, because the thread receiving signals might
      be blocked in a C call - previously there always be another thread
      stuck in awaitEvent() that would notice the signal, but that's not
      true now.  I can't see an easy fix yet.
      bb01a96b
  8. 12 Sep, 2004 1 commit
  9. 03 Sep, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-09-03 15:28:18 by simonmar] · 95ca6bff
      simonmar authored
      Cleanup: all (well, most) messages from the RTS now go through the
      functions in RtsUtils: barf(), debugBelch() and errorBelch().  The
      latter two were previously called belch() and prog_belch()
      respectively.  See the comments for the right usage of these message
      functions.
      
      One reason for doing this is so that we can avoid spurious uses of
      stdout/stderr by Haskell apps on platforms where we shouldn't be using
      them (eg. non-console apps on Windows).
      95ca6bff
  10. 15 Jul, 2004 2 commits
  11. 01 Oct, 2003 1 commit
    • wolfgang's avatar
      [project @ 2003-10-01 10:49:07 by wolfgang] · 324e96d2
      wolfgang authored
      Threaded RTS:
      Don't start new worker threads earlier than necessary.
      After this commit, a Haskell program that uses neither forkOS nor forkIO is
      really single-threaded (rather than using two OS threads internally).
      
      Some details:
      Worker threads are now only created when a capability is released, and
      only when
      (there are no worker threads)
      	&& (there are runnable Haskell threads ||
      	    there are Haskell threads blocked on IO or threadDelay)
      awaitEvent can now be called from bound thread scheduling loops
      (so that we don't have to create a worker thread just to run awaitEvent)
      324e96d2
  12. 26 Jun, 2003 1 commit
  13. 01 Apr, 2003 1 commit
    • sof's avatar
      [project @ 2003-04-01 15:05:13 by sof] · c49a6ca9
      sof authored
      Tidy up code that supports user/Haskell signal handlers.
      
      Signals.h now defines RTS_USER_SIGNALS when this is supported,
      which is then used elsewhere.
      c49a6ca9
  14. 29 Mar, 2003 1 commit
  15. 22 Feb, 2003 2 commits
    • sof's avatar
      [project @ 2003-02-22 06:13:41 by sof] · 384d5bcf
      sof authored
      bring getourtimeofday() proto into scope
      384d5bcf
    • sof's avatar
      [project @ 2003-02-22 04:51:50 by sof] · 557947d3
      sof authored
      Clean up code&interfaces that deals with timers and asynchrony:
      
      - Timer.{c,h} now defines the platform-independent interface
        to the timing services needed by the RTS. Itimer.{c,h} +
        win32/Ticker.{c,h} defines the OS-specific services that
        creates/destroys a timer.
      - For win32 plats, drop the long-standing use of the 'multimedia'
        API timers and implement the ticking service ourselves. Simpler
        and more flexible.
      - Select.c is now solely for platforms that use select() to handle
        non-blocking I/O & thread delays. win32/AwaitEvent.c provides
        the same API on the Win32 side.
      - support threadDelay on win32 platforms via worker threads.
      
      Not yet compiled up on non-win32 platforms; will do once checked in.
      557947d3
  16. 21 Feb, 2003 1 commit
    • sof's avatar
      [project @ 2003-02-21 05:34:12 by sof] · 5b4f5a6a
      sof authored
      Asynchronous / non-blocking I/O for Win32 platforms.
      
      This commit introduces a Concurrent Haskell friendly view of I/O on
      Win32 platforms. Through the use of a pool of worker Win32 threads, CH
      threads may issue asynchronous I/O requests without blocking the
      progress of other CH threads. The issuing CH thread is blocked until
      the request has been serviced though.
      
      GHC.Conc exports the primops that take care of issuing the
      asynchronous I/O requests, which the IO implementation now takes
      advantage of. By default, all Handles are non-blocking/asynchronous,
      but should performance become an issue, having a per-Handle flag for
      turning off non-blocking could easily be imagined&introduced.
      
      [Incidentally, this thread pool-based implementation could easily be
      extended to also allow Haskell code to delegate the execution of
      arbitrary pieces of (potentially blocking) external code to another OS
      thread. Given how relatively gnarly the locking story has turned out
      to be with the 'threaded' RTS, that may not be such a bad idea.]
      5b4f5a6a
  17. 25 Jan, 2003 1 commit
    • wolfgang's avatar
      [project @ 2003-01-25 15:54:48 by wolfgang] · af136096
      wolfgang authored
      This commit fixes many bugs and limitations in the threaded RTS.
      There are still some issues remaining, though.
      
      The following bugs should have been fixed:
      
      - [+] "safe" calls could cause crashes
      - [+] yieldToReturningWorker/grabReturnCapability
          -     It used to deadlock.
      - [+] couldn't wake blocked workers
          -     Calls into the RTS could go unanswered for a long time, and
                that includes ordinary callbacks in some circumstances.
      - [+] couldn't block on an MVar and expect to be woken up by a signal
            handler
          -     Depending on the exact situation, the RTS shut down or
                blocked forever and ignored the signal.
      - [+] The locking scheme in RtsAPI.c didn't work
      - [+] run_thread label in wrong place (schedule())
      - [+] Deadlock in GHC.Handle
          -     if a signal arrived at the wrong time, an mvar was never
                filled again
      - [+] Signals delivered to the "wrong" thread were ignored or handled
            too late.
      
      Issues:
      *) If GC can move TSO objects (I don't know - can it?), then ghci
      will occasionally crash when calling foreign functions, because the
      parameters are stored on the TSO stack.
      
      *) There is still a race condition lurking in the code
      (both threaded and non-threaded RTS are affected):
      If a signal arrives after the check for pending signals in
      schedule(), but before the call to select() in awaitEvent(),
      select() will be called anyway. The signal handler will be
      executed much later than expected.
      
      *) For Win32, GHC doesn't yet support non-blocking IO, so while a
      thread is waiting for IO, no call-ins can happen. If the RTS is
      blocked in awaitEvent, it uses a polling loop on Win32, so call-ins
      should work (although the polling loop looks ugly).
      
      *) Deadlock detection is disabled for the threaded rts, because I
      don't know how to do it properly in the presence of foreign call-ins
      from foreign threads.
      This causes the tests conc031, conc033 and conc034 to fail.
      
      *) "safe" is currently treated as "threadsafe". Implementing "safe" in
      a way that blocks other Haskell threads is more difficult than was
      thought at first. I think it could be done with a few additional lines
      of code, but personally, I'm strongly in favour of abolishing the
      distinction.
      
      *) Running finalizers at program termination is inefficient - there
      are two OS threads passing messages back and forth for every finalizer
      that is run. Also (just as in the non-threaded case) the finalizers
      are run in parallel to any remaining haskell threads and to any
      foreign call-ins that might still happen.
      af136096
  18. 24 Jul, 2002 1 commit
    • sof's avatar
      [project @ 2002-07-24 03:38:58 by sof] · 126ebbae
      sof authored
      awaitEvent: if select() reports EBADF,
      always unblock all waiting threads, even if
      the prior invocation of select() also
      elicited an EBADF.
      
      The 'smart' that was there previously runs
      the risk of working against us (if the EBADFs are
      coming from different fds), so the above
      scheme is preferable (and simpler.)
      126ebbae
  19. 17 Jul, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-07-17 09:21:48 by simonmar] · 7457757f
      simonmar authored
      Remove most #includes of system headers from Stg.h, and instead
      #include any required headers directly in each RTS source file.
      
      The idea is to (a) reduce namespace pollution from system headers that
      we don't need, (c) be clearer about dependencies on system things in
      the RTS, and (c) improve via-C compilation times (maybe).
      
      In practice though, HsBase.h #includes everything anyway, so the
      difference from the point of view of .hc source is minimal.  However,
      this makes it easier to move to zero-includes if we wanted to (see
      discussion on the FFI list; I'm still not sure that's possible but
      at least this is a step in the right direction).
      7457757f
  20. 09 Jul, 2002 1 commit
    • sof's avatar
      [project @ 2002-07-09 20:44:24 by sof] · d4fc9665
      sof authored
      awaitEvent: better handling of EBADFs, i.e., don't
      unconditionally barf() and exit if select() reports
      an EBADF. See source code comments for details, but
      in short, we attempt to unblock all threads to handle
      the error condition before bailing out.
      
      If only select() would indicate which file descriptor
      that was the bad one.
      
      (There's no good reason why select() errors other
      than EBADF could also be handled this way, but let's
      focus on it for now..)
      d4fc9665
  21. 13 Nov, 2001 1 commit
  22. 31 Oct, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-10-31 10:34:29 by simonmar] · 760f104f
      simonmar authored
      Fix a problem when a Haskell process is suspended/resumed using shell
      job control in Unix.  The shell tends to put stdin back into blocking
      mode before resuming the process, so we have to catch SIGCONT and put
      it back into O_NONBLOCK.
      
      Also:
      
        - fix a bug in the scheduler: reverse the order of the check
          for pending signals and the call to awaitEvent to block on I/O.
      
        - do a style sweep in Signals.c
      760f104f
  23. 14 Aug, 2001 1 commit
    • sewardj's avatar
      [project @ 2001-08-14 13:40:07 by sewardj] · bc5c8021
      sewardj authored
      Change the story about POSIX headers in C compilation.
      
      Until now, all C code in the RTS and library cbits has by default been
      compiled with settings for POSIXness enabled, that is:
         #define _POSIX_SOURCE   1
         #define _POSIX_C_SOURCE 199309L
         #define _ISOC9X_SOURCE
      If you wanted to negate this, you'd have to define NON_POSIX_SOURCE
      before including headers.
      
      This scheme has some bad effects:
      
      * It means that ccall-unfoldings exported via interfaces from a
        module compiled with -DNON_POSIX_SOURCE may not compile when
        imported into a module which does not -DNON_POSIX_SOURCE.
      
      * It overlaps with the feature tests we do with autoconf.
      
      * It seems to have caused borkage in the Solaris builds for some
        considerable period of time.
      
      The New Way is:
      
      * The default changes to not-being-in-Posix mode.
      
      * If you want to force a C file into Posix mode, #include as
        the **first** include the new file ghc/includes/PosixSource.h.
        Most of the RTS C sources have this include now.
      
      * NON_POSIX_SOURCE is almost totally expunged.  Unfortunately
        we have to retain some vestiges of it in ghc/compiler so that
        modules compiled via C on Solaris using older compilers don't
        break.
      bc5c8021
  24. 28 Feb, 2001 1 commit
  25. 27 Feb, 2001 1 commit
    • rrt's avatar
      [project @ 2001-02-27 12:43:45 by rrt] · 6339f4b0
      rrt authored
      mingwin "fixes": getourtimeofday now returns the right units, and awaitEvent
      fudged to use WinSock select(), so that although it doesn't work for file
      handles, at least it doesn't cause nasty crashes; instead it just blocks.
      6339f4b0
  26. 25 Aug, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-08-25 13:12:07 by simonmar] · 5a4ec937
      simonmar authored
      Change the way threadDelay# is implemented.
      
      We now use a list of sleeping threads sorted in increasing order by
      the time at which they will wake up.  This avoids us having to
      traverse the entire queue on each context switch.
      5a4ec937
  27. 23 Aug, 2000 1 commit
  28. 03 Apr, 2000 1 commit
    • rrt's avatar
      [project @ 2000-04-03 15:24:21 by rrt] · a0b380bb
      rrt authored
      Stopped getourtimeofday() being called under mingwin.
      MBlock.c: changed one instance of 128 * 1024 * 1024 into SIZE_RESERVED_POOL
      and added a TODO comment (bug in is_heap_alloced(), which won't work if
      more than one megablock is ever allocated).
      a0b380bb
  29. 23 Mar, 2000 1 commit
  30. 20 Mar, 2000 1 commit
    • andy's avatar
      [project @ 2000-03-20 09:42:49 by andy] · 90a6918a
      andy authored
      Adding an alternative to the "delay" system used for
      threads that are waiting for time to pass.
      
      This works on a target time basis, eliminating the
      need to use the ticky style counter.
      
      It is only enabled under:
      
      #if defined(INTERPRETER) && !defined(HAVE_SETITIMER)
      90a6918a
  31. 16 Mar, 2000 1 commit
  32. 17 Jan, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-01-17 17:33:30 by simonmar] · a5fda6b2
      simonmar authored
      Put a giant loop around awaitEvent, to protect against
      awaitEvent(rtsTrue) returning with no threads to run.
      
      This can happen if we try to delay for some time X, and select(2)
      decides to wait for a shorter time X-\delta instead.  It appears that
      Solaris is more prone to doing this than Linux.
      
      This fixes the "schedule: invalid whatNext field" crashes that people
      may have seen.
      a5fda6b2
  33. 13 Jan, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-01-13 12:40:15 by simonmar] · be587a37
      simonmar authored
      - remove AllBlocked scheduler return code.  Nobody owned up to having
        created it or even knowing what it was there for.
      
      - clean up fatal error condition handling somewhat.  The process
        exit code from a GHC program now indicates the kind of failure
        for certain kinds of exit:
      
      	general internal RTS error	254
      	program deadlocked		253
      	program interrupted (ctrl-C)	252
      	heap overflow			251
      	main thread killed		250
      
        and we leave exit codes 1-199 for the user (as is traditional at MS,
        200-249 are reserved for future expansion, and may contain
        undocumented extensions :-)
      be587a37
  34. 12 Jan, 2000 1 commit
  35. 24 Nov, 1999 1 commit
  36. 03 Nov, 1999 1 commit
    • simonmar's avatar
      [project @ 1999-11-03 15:04:25 by simonmar] · 5710a2d4
      simonmar authored
      - don't hold the scheduler lock while doing the select, since
        we might sit in there for a long time.
      
      - don't need the gettimeofday() hack on Linux, because select
        already returns the unslept time.
      5710a2d4
  37. 04 Oct, 1999 1 commit
  38. 13 Sep, 1999 1 commit