[project @ 2000-08-15 14:18:43 by simonmar]
[ghc-hetmet.git] / ghc / rts / Schedule.c
index 68f2210..39cd819 100644 (file)
@@ -1,5 +1,5 @@
 /* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.70 2000/05/08 15:57:01 simonmar Exp $
+ * $Id: Schedule.c,v 1.76 2000/08/15 14:18:43 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -516,7 +516,7 @@ schedule( void )
     }
     
     /* check for signals each time around the scheduler */
-#ifndef __MINGW32__
+#ifndef mingw32_TARGET_OS
     if (signals_pending()) {
       start_signal_handlers();
     }
@@ -850,12 +850,16 @@ schedule( void )
     
     cap->rCurrentTSO = t;
     
-    /* set the context_switch flag
+    /* context switches are now initiated by the timer signal, unless
+     * the user specified "context switch as often as possible", with
+     * +RTS -C0
      */
-    if (run_queue_hd == END_TSO_QUEUE)
-      context_switch = 0;
+    if (RtsFlags.ConcFlags.ctxtSwitchTicks == 0
+       && (run_queue_hd != END_TSO_QUEUE
+           || blocked_queue_hd != END_TSO_QUEUE))
+       context_switch = 1;
     else
-      context_switch = 1;
+       context_switch = 0;
 
     RELEASE_LOCK(&sched_mutex);
 
@@ -1189,7 +1193,7 @@ suspendThread( Capability *cap )
   ACQUIRE_LOCK(&sched_mutex);
 
   IF_DEBUG(scheduler,
-          sched_belch("thread %d did a _ccall_gc\n", cap->rCurrentTSO->id));
+          sched_belch("thread %d did a _ccall_gc", cap->rCurrentTSO->id));
 
   threadPaused(cap->rCurrentTSO);
   cap->rCurrentTSO->link = suspended_ccalling_threads;
@@ -1356,7 +1360,6 @@ createThread_(nat size, rtsBool have_lock)
   tso->why_blocked  = NotBlocked;
   tso->blocked_exceptions = NULL;
 
-  tso->splim        = (P_)&(tso->stack) + RESERVED_STACK_WORDS;
   tso->stack_size   = stack_size;
   tso->max_stack_size = round_to_mblocks(RtsFlags.GcFlags.maxStkSize) 
                               - TSO_STRUCT_SIZEW;
@@ -1593,6 +1596,9 @@ initScheduler(void)
   context_switch = 0;
   interrupted    = 0;
 
+  RtsFlags.ConcFlags.ctxtSwitchTicks =
+      RtsFlags.ConcFlags.ctxtSwitchTime / TICK_MILLISECS;
+
 #ifdef INTERPRETER
   ecafList = END_ECAF_LIST;
   clearECafTable();
@@ -2079,7 +2085,6 @@ threadStackOverflow(StgTSO *tso)
   diff = (P_)new_sp - (P_)tso->sp; /* In *words* */
   dest->su    = (StgUpdateFrame *) ((P_)dest->su + diff);
   dest->sp    = new_sp;
-  dest->splim = (P_)dest->splim + (nat)((P_)dest - (P_)tso);
   dest->stack_size = new_stack_size;
        
   /* and relocate the update frame list */
@@ -2717,7 +2722,7 @@ raiseAsync(StgTSO *tso, StgClosure *exception)
              
       ap->n_args = 2;
       ap->fun = cf->handler;   /* :: Exception -> IO a */
-      ap->payload[0] = (P_)exception;
+      ap->payload[0] = exception;
       ap->payload[1] = ARG_TAG(0); /* realworld token */
 
       /* throw away the stack from Sp up to and including the
@@ -2765,7 +2770,7 @@ raiseAsync(StgTSO *tso, StgClosure *exception)
     ap->fun    = (StgClosure *)sp[0];
     sp++;
     for(i=0; i < (nat)words; ++i) {
-      ap->payload[i] = (P_)*sp++;
+      ap->payload[i] = (StgClosure *)*sp++;
     }
     
     switch (get_itbl(su)->type) {