1. 25 Apr, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-04-25 14:22:29 by simonmar] · 8974a27f
      simonmar authored
      interruptStgRts: call threadRunnable().  This might not work properly
      from a signal handler, but it's all we can do (and seems to do
      something reasonable on Linux).
      8974a27f
  2. 22 Apr, 2005 4 commits
    • sof's avatar
      [project @ 2005-04-22 17:00:48 by sof] · ecb1a539
      sof authored
      [mingw only]
      Better handling of I/O request abortions upon throwing an exception
      to a Haskell thread. As was, a thread blocked on an I/O request was
      simply unblocked, but its corresponding worker thread wasn't notified
      that the request had been abandoned.
      
      This manifested itself in GHCi upon Ctrl-C being hit at the prompt -- the
      worker thread blocked waiting for input on stdin prior to Ctrl-C would
      stick around even though its corresponding Haskell thread had been
      thrown an Interrupted exception. The upshot was that the worker would
      consume the next character typed in after Ctrl-C, but then just dropping
      it. Dealing with this turned out to be even more interesting due to
      Win32 aborting any console reads when Ctrl-C/Break events are delivered.
      
      The story could be improved upon (at the cost of portability) by making
      the Scheduler able to abort worker thread system calls; as is, requests
      are cooperatively abandoned. Maybe later.
      
      Also included are other minor tidyups to Ctrl-C handling under mingw.
      
      Merge to STABLE.
      ecb1a539
    • simonmar's avatar
      [project @ 2005-04-22 14:19:07 by simonmar] · f4b45682
      simonmar authored
      Fix creation of raise_info closures: they're THUNKs
      f4b45682
    • simonmar's avatar
      [project @ 2005-04-22 11:20:22 by simonmar] · 3f9677ec
      simonmar authored
      rtsSupportsBoundThreads, isThreadBound: these should return rtsTrue
      for SMP too.
      3f9677ec
    • simonmar's avatar
      [project @ 2005-04-22 09:32:39 by simonmar] · 0f3205e6
      simonmar authored
      SMP: the rest of the changes to support safe thunk entry & updates.  I
      thought the compiler changes were independent, but I ended up breaking
      the HEAD, so I'll have to commit the rest.  non-SMP compilation should
      not be affected.
      0f3205e6
  3. 19 Apr, 2005 2 commits
  4. 13 Apr, 2005 1 commit
  5. 12 Apr, 2005 3 commits
    • simonmar's avatar
      [project @ 2005-04-12 10:07:56 by simonmar] · 211f35e0
      simonmar authored
      - prevent multiple threads from trying to do GC (deadlocks)
      
      - change the startWorkerThread flag to an integer, prevents
        spurious extra tasks from being started at startup time
      211f35e0
    • simonmar's avatar
      [project @ 2005-04-12 09:17:47 by simonmar] · 91831575
      simonmar authored
      The in_haskell sanity check should be per-Capability rather than global.
      
      I just ran a Haskell program in 8 pthreads simultaneously :-)
      91831575
    • simonmar's avatar
      [project @ 2005-04-12 09:04:23 by simonmar] · 693550d9
      simonmar authored
      Per-task nurseries for SMP.  This was kind-of implemented before, but
      it's much cleaner now.  There is now one *step* per capability, so we
      have somewhere to hang the block count.  So for SMP, there are simply
      multiple instances of generation 0 step 0.  The rNursery entry in the
      register table now points to the step rather than the head block of
      the nurersy.
      693550d9
  6. 07 Apr, 2005 3 commits
    • simonmar's avatar
      [project @ 2005-04-07 21:27:10 by simonmar] · ce1a3417
      simonmar authored
      Fix compiling for way p
      ce1a3417
    • simonmar's avatar
      [project @ 2005-04-07 15:56:34 by simonmar] · 5000229d
      simonmar authored
      A much simpler way of stopping all the other threads to do a GC in SMP
      mode: the thread that wants to do GC just acquires all the
      capabilities, and releases them after doing the GC.
      5000229d
    • 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
  7. 06 Apr, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-04-06 15:27:06 by simonmar] · 9a92cb1c
      simonmar authored
      Revamp the Task API: now we use the same implementation for threaded
      and SMP.  We also keep per-task timing stats in the threaded RTS now,
      which makes the output of +RTS -sstderr more useful.
      9a92cb1c
  8. 05 Apr, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-04-05 12:19:54 by simonmar] · 16214216
      simonmar authored
      Some multi-processor hackery, including
      
        - Don't hang blocked threads off BLACKHOLEs any more, instead keep
          them all on a separate queue which is checked periodically for
          threads to wake up.
      
          This is good because (a) we don't have to worry about locking the
          closure in SMP mode when we want to block on it, and (b) it means
          the standard update code doesn't need to wake up any threads or
          check for a BLACKHOLE_BQ, simplifying the update code.
      
          The downside is that if there are lots of threads blocked on
          BLACKHOLEs, we might have to do a lot of repeated list traversal.
          We don't expect this to be common, though.  conc023 goes slower
          with this change, but we expect most programs to benefit from the
          shorter update code.
      
        - Fixing up the Capability code to handle multiple capabilities (SMP
          mode), and related changes to get the SMP mode at least building.
      16214216
    • simonmar's avatar
      [project @ 2005-04-05 09:28:32 by simonmar] · f50d2bf0
      simonmar authored
      type fixups
      f50d2bf0
  9. 04 Apr, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-04-04 13:51:26 by simonmar] · 1347b6d5
      simonmar authored
      Big cleanup of the scheduler.
      
      The main idea here was to extract as much stuff as possible from the
      scheduler loop into seprate functions, so as to better expose the
      control structure of the scheduler.  Now, the scheduler loop is down
      to some 300+ lines; there's some more code that could be extracted,
      but I think it looks pretty good now.
      
      This work is partly due to an initial cleanup by the GRAN/PAR folks,
      heavily re-worked by me.
      1347b6d5
  10. 05 Mar, 2005 1 commit
    • panne's avatar
      [project @ 2005-03-05 16:19:14 by panne] · 9c5d640b
      panne authored
      Nuked dead code. Now the RTS is free of warnings, except for failed
      inlinings of thread_obj, processHeapClosureForDead, pop, and
      push. Should we remove their "inline" modifier?
      9c5d640b
  11. 15 Feb, 2005 1 commit
  12. 10 Feb, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-02-10 13:01:52 by simonmar] · e7c3f957
      simonmar authored
      GC changes: instead of threading old-generation mutable lists
      through objects in the heap, keep it in a separate flat array.
      
      This has some advantages:
      
        - the IND_OLDGEN object is now only 2 words, so the minimum
          size of a THUNK is now 2 words instead of 3.  This saves
          some amount of allocation (about 2% on average according to
          my measurements), and is more friendly to the cache by
          squashing objects together more.
      
        - keeping the mutable list separate from the IND object
          will be necessary for our multiprocessor implementation.
      
        - removing the mut_link field makes the layout of some objects
          more uniform, leading to less complexity and special cases.
      
        - I also unified the two mutable lists (mut_once_list and mut_list)
          into a single mutable list, which lead to more simplifications
          in the GC.
      e7c3f957
  13. 03 Feb, 2005 1 commit
  14. 02 Feb, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-02-02 12:41:50 by simonmar] · 268d028c
      simonmar authored
      Add a helpful sanity check: if we try to re-enter the scheduler from
      Haskell code without going via suspendThread()/resumeThread(), such as
      when you have a 'foreign import unsafe' that should be 'safe', then you
      get an error message.
      268d028c
  15. 28 Jan, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-01-28 12:55:17 by simonmar] · 153b9cb9
      simonmar authored
      Rationalise the BUILD,HOST,TARGET defines.
      
      Recall that:
      
        - build is the platform we're building on
        - host is the platform we're running on
        - target is the platform we're generating code for
      
      The change is that now we take these definitions as applying from the
      point of view of the particular source code being built, rather than
      the point of view of the whole build tree.
      
      For example, in RTS and library code, we were previously testing the
      TARGET platform.  But under the new rule, the platform on which this
      code is going to run is the HOST platform.  TARGET only makes sense in
      the compiler sources.
      
      In practical terms, this means that the values of BUILD, HOST & TARGET
      may vary depending on which part of the build tree we are in.
      
      Actual changes:
      
       - new file: includes/ghcplatform.h contains platform defines for
         the RTS and library code.
      
       - new file: includes/ghcautoconf.h contains the autoconf settings
         only (HAVE_BLAH).  This is so that we can get hold of these
         settings independently of the platform defines when necessary
         (eg. in GHC).
      
       - ghcconfig.h now #includes both ghcplatform.h and ghcautoconf.h.
      
       - MachRegs.h, which is included into both the compiler and the RTS,
         now has to cope with the fact that it might need to test either
         _TARGET_ or _HOST_ depending on the context.
      
       - the compiler's Makefile now generates
           stage{1,2,3}/ghc_boot_platform.h
         which contains platform defines for the compiler.  These differ
         depending on the stage, of course: in stage2, the HOST is the
         TARGET of stage1.  This was wrong before.
      
       - The compiler doesn't get platform info from Config.hs any more.
         Previously it did (sometimes), but unless we want to generate
         a new Config.hs for each stage we can't do this.
      
       - GHC now helpfully defines *_{BUILD,HOST}_{OS,ARCH} automatically
         in CPP'd Haskell source.
      
       - ghcplatform.h defines *_TARGET_* for backwards compatibility
         (ghcplatform.h is included by ghcconfig.h, which is included by
         config.h, so code which still #includes config.h will get the TARGET
         settings as before).
      
       - The Users's Guide is updated to mention *_HOST_* rather than
         *_TARGET_*.
      
       - coding-style.html in the commentary now contains a section on
         platform defines.  There are further doc updates to come.
      
      Thanks to Wolfgang Thaller for pointing me in the right direction.
      153b9cb9
  16. 21 Jan, 2005 1 commit
    • sof's avatar
      [project @ 2005-01-21 19:58:51 by sof] · c7fd6356
      sof authored
      win32 only:
        Tidy up delivery and handling of console events by having the low-level
        console event handler signal the RTS thread blocked waiting for I/O.
      c7fd6356
  17. 13 Jan, 2005 1 commit
  18. 12 Jan, 2005 2 commits
  19. 08 Dec, 2004 1 commit
  20. 18 Nov, 2004 1 commit
  21. 10 Nov, 2004 1 commit
    • wolfgang's avatar
      [project @ 2004-11-10 04:17:50 by wolfgang] · 845db818
      wolfgang authored
      64-bit fix:
      Change the type of context_switch from 'nat' to 'int'.
      It's accessed as CInt from cmm code, and sizeof(nat) > sizeof(int)
      on many 64-bit platforms.
      845db818
  22. 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
  23. 03 Oct, 2004 1 commit
  24. 22 Sep, 2004 1 commit
  25. 12 Sep, 2004 1 commit
  26. 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
  27. 19 Aug, 2004 1 commit
  28. 13 Aug, 2004 1 commit
  29. 09 Aug, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-08-09 14:27:53 by simonmar] · 05881eca
      simonmar authored
      Two changes:
      
        - newly created or unblocked threads go to the back of the run
          queue.  This is fairer because it avoids possible starvation.
          Fixes problem with conc004 test going much slower with optimisation.
      
        - The context switch flag is only reset after a yield.  Previously,
          it was being reset before we ran a thread, which meant that a tick
          that arrived during GC would be lost, and a thread doing lots of
          GC could hog the CPU.  Now, GC is effectively counted as part of
          the last running thread's timeslice.
      
      MERGE TO STABLE.
      05881eca
  30. 27 May, 2004 1 commit