1. 15 Feb, 2005 1 commit
  2. 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
  3. 03 Feb, 2005 1 commit
  4. 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
  5. 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
  6. 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
  7. 13 Jan, 2005 1 commit
  8. 12 Jan, 2005 2 commits
  9. 08 Dec, 2004 1 commit
  10. 18 Nov, 2004 1 commit
  11. 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
  12. 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
  13. 03 Oct, 2004 1 commit
  14. 22 Sep, 2004 1 commit
  15. 12 Sep, 2004 1 commit
  16. 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
  17. 19 Aug, 2004 1 commit
  18. 13 Aug, 2004 1 commit
  19. 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
  20. 27 May, 2004 2 commits
    • simonmar's avatar
      [project @ 2004-05-27 15:21:37 by simonmar] · e663fcfa
      simonmar authored
      Remove part of previous patch which was for debugging only.
      e663fcfa
    • simonmar's avatar
      [project @ 2004-05-27 15:18:31 by simonmar] · 86e487a2
      simonmar authored
      Fix a nasty bug: when saving errno in the TSO after running a thread,
      beware that the TSO might have moved, e.g. if the thread made a safe
      foreign call in the threaded RTS and a GC happened.
      
      We have to grab the new location of the TSO *before* saving errno.
      
      MERGE TO STABLE
      
      This was the most interesting bug hunt I've had in a while.  The crash
      only showed up in about 1 in 4 runs of a program with 1000 Haskell
      threads, running on the threaded RTS.  To make things worse, gdb
      doesn't support watchpoints in programs with multiple threads... :-/
      86e487a2
  21. 06 May, 2004 1 commit
    • wolfgang's avatar
      [project @ 2004-05-06 12:20:04 by wolfgang] · b44a2c87
      wolfgang authored
      Threaded RTS: Fix a deadlock situation
      
      The flag startingWorkerThread that is used by startSchedulerTaskIfNecessary
      (in Schedule.c) has to be reset if startTask (in Task.c) decides not to
      start another task after all (if a task is already waiting).
      When the flag isn't reset, this leads to a deadlock the next time a new
      worker thread is actually needed.
      
      MERGE TO STABLE
      b44a2c87
  22. 13 Apr, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-04-13 13:43:11 by simonmar] · 364291e8
      simonmar authored
      merge rev. 1.173.2.21:
      
      Fix bug in deleteAllThreads() - shouldn't throw away the contents of
      the run queue, we still need to deal with those ThreadKilled threads.
      364291e8
  23. 13 Mar, 2004 1 commit
  24. 01 Mar, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-03-01 14:18:35 by simonmar] · a20ec0ce
      simonmar authored
      Threaded RTS improvements:
      
        - Make the main_threads list doubly linked.  Have threads
          remove themselves from this list when they complete, rather
          than searching for completed main threads each time around
          the scheduler loop.  This removes an O(n) loop from the
          scheduler, but adds some new constraints (basically completed
          threads must remain on the run queue until dealt with, including
          threads which have been killed by an async exception).
      
        - Add a pointer from the TSO to the StgMainThread struct, for
          main threads.  This avoids a number of places where we had
          to traverse the list of main threads to find the right one,
          including one place in the scheduler loop.  Adding a field to
          a TSO is cheap.
      
        - taskStart: we should be resetting the startingWorkerThread flag
          in here.  Not sure why we aren't; maybe this got lost at some point.
      
        - Use the BlockedOnCCall flags in the non-threaded RTS too.  Q: what
          should happen if a thread does a foreign call which re-enters the
          RTS, and then sends an async exception to the original thread?
          Answer: it should deadlock, which it does in the threaded RTS, and
          this commit makes it do so in the non-threaded RTS too (see
          testsuite/tests/concurrent/should_run/conc040.hs).
      a20ec0ce
  25. 27 Feb, 2004 4 commits
  26. 26 Feb, 2004 3 commits
  27. 25 Feb, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-02-25 17:35:44 by simonmar] · dc167cca
      simonmar authored
      Feeble performance hack for the threaded RTS: instead of
      allocating/releasing a new condition variable for each new call-in, we
      just cache one in the RTS and re-use it for the next call.
      
      On a little test I have here which does lots of call-ins on Windows,
      this reduces the slowdown for using the threaded RTS from a factor of
      7-8 down to a factor of 4-5.  I'm aiming for a factor of 2 or better...
      dc167cca
  28. 18 Dec, 2003 1 commit
  29. 16 Dec, 2003 1 commit
    • simonmar's avatar
      [project @ 2003-12-16 13:27:31 by simonmar] · de02e02a
      simonmar authored
      Clean up Capability API
      ~~~~~~~~~~~~~~~~~~~~~~~
      
      - yieldToReturningWorker() is now yieldCapability(), and performs all
        kinds of yielding (both to returning workers and passing to other
        OS threads).  yieldCapabiltiy() does *not* re-acquire a capability.
      
      - waitForWorkCapabilty() is now waitForCapability().
      
      - releaseCapbility() also releases the capability when passing to
        another OS thread.  It is the only way to release a capability (apart
        from yieldCapability(), which calls releaseCapability() internally).
      
      - passCapability() and passCapabilityToWorker() now do not release the
        capability.  They just set a flag to indicate where the capabiliy
        should go when it it next released.
      
      
      Other cleanups:
      
        - Removed all the SMP stuff from Schedule.c.  It had extensive bitrot,
          and was just obfuscating the code.  If it is ever needed again,
          it can be resurrected from CVS.
      
        - Removed some other dead code in Schedule.c, in an attempt to make
          this file more manageable.
      de02e02a
  30. 12 Dec, 2003 1 commit
  31. 05 Dec, 2003 1 commit
  32. 12 Nov, 2003 1 commit
    • sof's avatar
      [project @ 2003-11-12 17:49:05 by sof] · 20593d1d
      sof authored
      Tweaks to have RTS (C) sources compile with MSVC. Apart from wibbles
      related to the handling of 'inline', changed Schedule.h:POP_RUN_QUEUE()
      not to use expression-level statement blocks.
      20593d1d
  33. 05 Oct, 2003 1 commit
    • panne's avatar
      [project @ 2003-10-05 20:18:36 by panne] · 45ee5a69
      panne authored
      Unbreak the 2nd stage of non-threaded-RTS builds by #ifdefing out a
      call to wakeBlockedWorkerThread. This should probably fixed more
      cleanly by taking an OO view, i.e. always defining this function, but
      doing nothing in the non-threaded case. The final decision on this
      issue is left to the Masters of the Threads (tm)...
      45ee5a69