Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/runtime/mach-dep/signal-util.c
ViewVC logotype

Diff of /sml/trunk/src/runtime/mach-dep/signal-util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1780, Mon May 2 20:59:52 2005 UTC revision 1781, Tue May 3 17:26:49 2005 UTC
# Line 25  Line 25 
25   */   */
26  void ChooseSignal (vproc_state_t *vsp)  void ChooseSignal (vproc_state_t *vsp)
27  {  {
28      ASSERT(vsp->vp_numInQ > 0);      int         i, j, delta;
29    
30      /* scan the signal counts looking for a signal that needs to be handled. */
31        i = vsp->vp_nextPendingSig;
32        j = 0;
33        do {
34            ASSERT (j++ < NUM_SIGS);
35            i++;
36            if (i == SIGMAP_SZ) i = MIN_SYSTEM_SIG;
37            delta = vsp->vp_sigCounts[i].nReceived - vsp->vp_sigCounts[i].nHandled;
38        } while (delta == 0);
39        vsp->vp_nextPendingSig = i;
40    
41    /* record the signal and count */    /* record the signal and count */
42      vsp->vp_sigCode = vsp->vp_pendingSigQ[vsp->vp_nextPendingSig].sigNum;      vsp->vp_sigCode = i;
43      vsp->vp_sigCount = vsp->vp_pendingSigQ[vsp->vp_nextPendingSig].count;      vsp->vp_sigCount = delta;
44      if (IS_SYSTEM_SIG(vsp->vp_sigCode))      vsp->vp_sigCounts[i].nHandled += delta;
45          vsp->vp_numPendingSysSigs -= vsp->vp_sigCount;      vsp->vp_totalSigCount.nHandled += delta;
     else  
         vsp->vp_numPendingSigs -= vsp->vp_sigCount;  
   
   /* advance the pending queue */  
     if ((--vsp->vp_numInQ == 0) || (++vsp->vp_nextPendingSig == NUM_SIGS))  
         vsp->vp_nextPendingSig = 0;  
46    
47  #ifdef SIGNAL_DEBUG  #ifdef SIGNAL_DEBUG
48  SayDebug ("ChooseSignal: sig = %d, count = %d\n",  SayDebug ("ChooseSignal: sig = %d, count = %d\n",
# Line 47  Line 52 
52  } /* end of ChooseSignal */  } /* end of ChooseSignal */
53    
54    
 /* EnqueueSignal:  
  *  
  * Add a signal to the pending queue; if the signal is already present, then  
  * bump its count.  
  */  
 void EnqueueSignal (vproc_state_t *vsp, int sigCode)  
 {  
     int         i, j;  
   
 #ifdef SIGNAL_DEBUG  
 SayDebug("EnqueueSignal: numInQ = %d, sig = %d\n", vsp->vp_numInQ, sigCode);  
 #endif  
   
     ASSERT(vsp->vp_numInQ >= 0);  
   
     for (i = vsp->vp_nextPendingSig, j = vsp->vp_numInQ;  --j >= 0; ) {  
         if (vsp->vp_pendingSigQ[i].sigNum == sigCode)  
             break;  
         if (++i == NUM_SIGS) i = 0;  
     }  
     if (j < 0) {  
         vsp->vp_pendingSigQ[i].sigNum = sigCode;  
         vsp->vp_pendingSigQ[i].count = 1;  
         vsp->vp_numInQ++;  
     }  
     else  
         vsp->vp_pendingSigQ[i].count++;  
   
 } /* end of EnqueueSignal */  
   
   
55  /* MakeResumeCont:  /* MakeResumeCont:
56   *   *
57   * Build the resume continuation for a signal or poll event handler.   * Build the resume continuation for a signal or poll event handler.
# Line 168  Line 142 
142      msp->ml_calleeSave[2]       = contClosure[9];      msp->ml_calleeSave[2]       = contClosure[9];
143    
144  } /* end of LoadResumeState */  } /* end of LoadResumeState */
   
   
 /* GCSignal:  
  *  
  * Record a garbage collection signal (if enabled).  Return true, if a signal  
  * was recorded.  
  */  
 bool_t GCSignal (vproc_state_t *vsp)  
 {  
     if (vsp->vp_gcSigState == ML_SIG_ENABLED) {  
         vsp->vp_numPendingSigs++;  
         EnqueueSignal (vsp, RUNSIG_GC);  
         return TRUE;  
     }  
     else  
         return FALSE;  
   
 } /* end of GCSignal */  
   

Legend:
Removed from v.1780  
changed lines
  Added in v.1781

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0