[project @ 2003-06-19 10:35:37 by simonmar]
[ghc-hetmet.git] / ghc / rts / Schedule.c
index d572b15..1afc9fe 100644 (file)
@@ -1,5 +1,5 @@
 /* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.166 2003/04/01 15:05:15 sof Exp $
+ * $Id: Schedule.c,v 1.170 2003/06/19 10:35:37 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -217,14 +217,15 @@ static StgThreadID next_thread_id = 1;
 /* The smallest stack size that makes any sense is:
  *    RESERVED_STACK_WORDS    (so we can get back from the stack overflow)
  *  + sizeofW(StgStopFrame)   (the stg_stop_thread_info frame)
- *  + 1                       (the realworld token for an IO thread)
  *  + 1                       (the closure to enter)
+ *  + 1                              (stg_ap_v_ret)
+ *  + 1                              (spare slot req'd by stg_ap_v_ret)
  *
  * A thread with this stack will bomb immediately with a stack
  * overflow, which will increase its stack size.  
  */
 
-#define MIN_STACK_WORDS (RESERVED_STACK_WORDS + sizeofW(StgStopFrame) + 2)
+#define MIN_STACK_WORDS (RESERVED_STACK_WORDS + sizeofW(StgStopFrame) + 3)
 
 
 #if defined(GRAN)
@@ -1494,8 +1495,9 @@ run_thread:
  * Singleton fork(). Do not copy any running threads.
  * ------------------------------------------------------------------------- */
 
-StgInt forkProcess(StgTSO* tso) {
-
+StgInt
+forkProcess(StgTSO* tso)
+{
 #ifndef mingw32_TARGET_OS
   pid_t pid;
   StgTSO* t,*next;
@@ -1571,7 +1573,8 @@ StgInt forkProcess(StgTSO* tso) {
  * Locks: sched_mutex held.
  * ------------------------------------------------------------------------- */
    
-void deleteAllThreads ( void )
+void
+deleteAllThreads ( void )
 {
   StgTSO* t, *next;
   IF_DEBUG(scheduler,sched_belch("deleting all threads"));
@@ -1669,11 +1672,7 @@ suspendThread( StgRegTable *reg,
 
 StgRegTable *
 resumeThread( StgInt tok,
-             rtsBool concCall
-#if !defined(RTS_SUPPORTS_THREADS)
-              STG_UNUSED
-#endif
-             )
+             rtsBool concCall STG_UNUSED )
 {
   StgTSO *tso, **prev;
   Capability *cap;
@@ -2619,7 +2618,7 @@ performGCWithRoots(void (*get_roots)(evac_fn))
 static StgTSO *
 threadStackOverflow(StgTSO *tso)
 {
-  nat new_stack_size, new_tso_size, diff, stack_words;
+  nat new_stack_size, new_tso_size, stack_words;
   StgPtr new_sp;
   StgTSO *dest;
 
@@ -2660,8 +2659,7 @@ threadStackOverflow(StgTSO *tso)
   memcpy(new_sp, tso->sp, stack_words * sizeof(W_));
 
   /* relocate the stack pointers... */
-  diff = (P_)new_sp - (P_)tso->sp; /* In *words* */
-  dest->sp    = new_sp;
+  dest->sp         = new_sp;
   dest->stack_size = new_stack_size;
        
   /* Mark the old TSO as relocated.  We have to check for relocated