1. 04 Nov, 2005 1 commit
  2. 03 Nov, 2005 2 commits
  3. 02 Nov, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-11-02 13:04:55 by simonmar] · db2468da
      simonmar authored
      when shutting down, don't allow a worker to exit until the run queue
      is empty, because the thread in exitScheduler() is waiting for this.
      db2468da
    • simonmar's avatar
      [project @ 2005-11-02 12:26:21 by simonmar] · d9dfeb2a
      simonmar authored
      scheduleHandleStackOverflow: fix bug in non-threaded RTS - if
      (task->tso != NULL), then (task->tso) is not necessarily the TSO we
      are running (in the threaded RTS it is).
      
      Also fix a few non-threaded warnings while I'm here.
      d9dfeb2a
  4. 27 Oct, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-10-27 15:26:06 by simonmar] · 677c6345
      simonmar authored
      - Very simple work-sharing amongst Capabilities: whenever a Capability
        detects that it has more than 1 thread in its run queue, it runs
        around looking for empty Capabilities, and shares the threads on its
        run queue equally with the free Capabilities it finds.
      
      - unlock the garbage collector's mutable lists, by having private
        mutable lists per capability (and per generation).  The private
        mutable lists are moved onto the main mutable lists at each GC.
        This pulls the old-generation update code out of the storage manager
        mutex, which is one of the last remaining causes of (alleged) contention.
      
      - Fix some problems with synchronising when a GC is required.  We should
        synchronise quicker now.
      677c6345
  5. 26 Oct, 2005 4 commits
    • simonmar's avatar
      [project @ 2005-10-26 15:36:06 by simonmar] · 9348149e
      simonmar authored
      Package up the various properties of Capabilities/Tasks that we were
      asserting all over the place, and put them in a single macro
      ASSERT_CAPABILITY_INVARIANTS().
      9348149e
    • simonmar's avatar
      [project @ 2005-10-26 15:20:59 by simonmar] · 05fa9867
      simonmar authored
      - forkProcess fix: add a forgotten rts_unlock()
      - add a couple more ASSERTs
      05fa9867
    • simonmar's avatar
      [project @ 2005-10-26 11:41:51 by simonmar] · 48d21c1f
      simonmar authored
      fix to previous change: allow workers to exit
      48d21c1f
    • simonmar's avatar
      [project @ 2005-10-26 10:42:54 by simonmar] · 7c82b4a8
      simonmar authored
      - change the type of StgRun(): now we return the Capability that the
        thread currently holds.  The return status of the thread is now
        stored in cap->r.rRet (a new slot in the reg table).
      
        This was necessary because on return from StgRun(), the current
        TSO may be blocked, so it no longer belongs to us.  If it is a bound
        thread, then the Task may have been already woken up on another
        Capability, so the scheduler can't use task->cap to find the
        capability it currently owns.
      
      - when shutting down, allow a bound thread to remove its TSO from
        the run queue when exiting (eliminates an error condition in
        releaseCapability()).
      7c82b4a8
  6. 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
  7. 20 Oct, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-10-20 11:45:19 by simonmar] · 4f0f4342
      simonmar authored
      changes to exitScheduler(): instead of waiting for all the tasks to
      stop, which is unreasonable, we just wait for the run queue to drain.
      This is much quicker, but not ideal (see comments).
      4f0f4342
  8. 12 Oct, 2005 1 commit
  9. 16 Sep, 2005 1 commit
  10. 12 Sep, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-09-12 16:00:43 by simonmar] · ff05c281
      simonmar authored
      raiseAsync_: raise_info closure is header + MIN_UPD_SIZE, not header +
      1 words.  (MIN_UPD_SIZE is 1 in the HEAD so this has no effect, but
      it'll make a difference on STABLE).
      ff05c281
  11. 24 Aug, 2005 1 commit
  12. 12 Jul, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-07-12 13:34:03 by simonmar] · f85ef2f1
      simonmar authored
      schedulDoGC: when traversing the all_threads list checking for invalid
      transactions we were bogusly following the link field rather than the
      global_link field.
      f85ef2f1
  13. 11 Jul, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-07-11 12:29:28 by simonmar] · b8105b2b
      simonmar authored
      awakenBlockedQueue(): check for NULL.  This is a hack to workaround a
      bug that occurs when async exceptions, unsafePerformIO, and
      interruptible operations are used together.  See the comment in
      Exceptions.cmm and bug #1235728 for more details.
      b8105b2b
  14. 28 Jun, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-06-28 13:44:28 by simonmar] · 9c1b774a
      simonmar authored
      Add a comment that grabbing all the capabilities before GC causes the
      thread->capability hash table to acquire multiple entries for the
      current thread, which seems to be harmless.
      9c1b774a
  15. 27 May, 2005 1 commit
  16. 25 May, 2005 2 commits
  17. 23 May, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-05-23 15:44:10 by simonmar] · 6d16c476
      simonmar authored
      Simplify and improve the Capability-passing machinery for bound
      threads.
      
      The old story was quite complicated: if you find a thread on the run
      queue which the current task can't run, you had to call
      passCapability(), which set a flag saying where the next Capability
      was to go, and then release the Capability.  When multiple
      Capabilities are flying around, it's not clear how this story should
      extend.
      
      The new story is much simpler: each time around the scheduler loop,
      the task looks to see whether it can make any progress, and if not, it
      releases its Capability and wakes up a task which *can* make some
      progress.  The predicate for whether we can make any progress is
      encapsulated in the (inline) function ANY_WORK_FOR_ME(Condition).
      Waking up an appropriate task is encapsulated in the function
      threadRunnable() (previously it was in two places).
      
      The logic in Capability.c is simpler, but unfortunately it is now more
      closely connected with the Scheduler, because it inspects the run
      queue.  However, performance when communicating between bound and
      unbound threads might be better.
      
      The concurrency tests still work, so hopefully this hasn't broken
      anything.
      6d16c476
    • simonmar's avatar
      [project @ 2005-05-23 13:39:55 by simonmar] · 58150db0
      simonmar authored
      - scheduleDetectDeadlock() should invoke GarbageCollect() via
        scheduleDoGC(), which collects the Capabilities first.
      
      - scheduleDoGC() doesn't need the Capability.  Also, it appears that
        there was an out-of-bounds array access in here.
      
      - add printThreadQueue(), useful from gdb.
      
      - fix a couple of warnings.
      58150db0
  18. 21 May, 2005 1 commit
  19. 19 May, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-05-19 13:21:55 by simonmar] · 3595da95
      simonmar authored
      - Move the call to threadPaused() from the scheduler into STG land,
        and put it in a new code fragment (stg_returnToSched) that we pass
        through every time we return from STG to the scheduler.  Also, the
        SAVE_THREAD_STATE() is now in stg_returnToSched which might save a
        little code space (at the expense of an extra jump for every return
        to the scheduler).
      
      - SMP: when blocking on an MVar, we now wait until the thread has been
        made fully safe and placed on the blocked queue of the MVar before
        we unlock the MVar.  This closes a race whereby another OS thread could
        begin waking us up before the current TSO had been properly tidied up.
      
      Fixes one cause of crashes when using MVars with SMP.  I still have a
      deadlock problem to track down.
      3595da95
  20. 16 May, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-05-16 09:24:53 by simonmar] · 313797f8
      simonmar authored
      - re-initalise cap on returning from STG land, because we might now
        have a different capability.  ToDo: we should pass it back somehow,
        rather than looking it up in the hash table
      
      - export unblockOneLocked (we'll need this later)
      313797f8
  21. 12 May, 2005 1 commit
  22. 11 May, 2005 2 commits
  23. 09 May, 2005 2 commits
  24. 05 May, 2005 2 commits
  25. 27 Apr, 2005 1 commit
  26. 25 Apr, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-04-25 15:36:28 by simonmar] · b050008e
      simonmar authored
      Partial support for deadlock detection in the threaded/SMP RTS.
      
      The idea is to wait until a complete time slice has gone by without
      running any Haskell code, and then try doing a GC to detect deadlocked
      threads.
      
      This kind of works: but we can only wake up a worker thread from the
      signal handler if there's another worker running - we can't wake up the
      current thread, it seems.
      b050008e
    • 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
  27. 22 Apr, 2005 3 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