Changeset 6413 for branches/x8664-call


Ignore:
Timestamp:
May 4, 2007, 5:18:51 AM (13 years ago)
Author:
gb
Message:

Try to make use of mach_exception_lock conditional, disable it.
(Need to try this for x86-64 as well.)

Location:
branches/x8664-call/ccl/lisp-kernel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/x8664-call/ccl/lisp-kernel/lisp-exceptions.h

    r6403 r6413  
    128128exception_fn_name( ExceptionInformation *, int, char *, size_t );
    129129
     130/* Need to define this here */
     131#ifdef DARWIN
     132#define USE_MACH_EXCEPTION_LOCK 0
     133#endif
     134
    130135
    131136#ifdef PPC
     
    140145void resume_other_threads(Boolean);
    141146
     147
    142148#endif /* __lisp_exceptions_h__ */
    143149
  • branches/x8664-call/ccl/lisp-kernel/ppc-exceptions.c

    r6409 r6413  
    22322232#ifdef DARWIN
    22332233
     2234
    22342235#define TCR_FROM_EXCEPTION_PORT(p) ((TCR *)((natural)p))
    22352236#define TCR_TO_EXCEPTION_PORT(tcr) ((mach_port_t)((natural)(tcr)))
    22362237
     2238#if USE_MACH_EXCEPTION_LOCK
    22372239pthread_mutex_t _mach_exception_lock, *mach_exception_lock;
    2238 
     2240#endif
    22392241
    22402242#define LISP_EXCEPTIONS_HANDLED_MASK \
     
    26642666#endif
    26652667
    2666   if (pthread_mutex_trylock(mach_exception_lock) == 0) {
     2668  if ((!USE_MACH_EXCEPTION_LOCK) || (pthread_mutex_trylock(mach_exception_lock) == 0)) {
    26672669    if (tcr->flags & (1<<TCR_FLAG_BIT_PENDING_EXCEPTION)) {
    26682670      CLR_TCR_FLAG(tcr,TCR_FLAG_BIT_PENDING_EXCEPTION);
  • branches/x8664-call/ccl/lisp-kernel/ppc-exceptions.h

    r5284 r6413  
    388388#include <mach/machine/thread_status.h>
    389389
     390#if USE_MACH_EXCEPTION_LOCK
    390391pthread_mutex_t *mach_exception_lock;
     392#endif
    391393#endif
    392394
  • branches/x8664-call/ccl/lisp-kernel/thread_manager.c

    r6218 r6413  
    10661066tcr_suspend_ack(TCR *tcr)
    10671067{
    1068   /* On Linux, it's safe to wait forever */
    1069   /*#ifndef DARWIN */
    1070 #if 1
    10711068  if (tcr->flags & (1<<TCR_FLAG_BIT_SUSPEND_ACK_PENDING)) {
    10721069    SEM_WAIT_FOREVER(tcr->suspend);
     
    10781075  }
    10791076  return true;
    1080 #else
    1081   /* if the ACK_PENDING flag is already clear, return true immediately
    1082      (in case the caller neglects to check for this */
    1083   if (!(tcr->flags & (1<<TCR_FLAG_BIT_SUSPEND_ACK_PENDING))) {
    1084     return true;
    1085   } else {
    1086     /* Safe to wait forever if Mach exception handling is disabled */
    1087     if (!use_mach_exception_handling) {
    1088       SEM_WAIT_FOREVER(tcr->suspend);
    1089       CLR_TCR_FLAG(tcr,TCR_FLAG_BIT_SUSPEND_ACK_PENDING);
    1090       return true;
    1091     }
    1092     /* If there's an exception pending on this thread, release the
    1093        exception lock so that the thread can enter a runnable state.
    1094        It should be safe to wait forever for the semaphore once it's
    1095        runnable. */
    1096     if (tcr->flags & (1<<TCR_FLAG_BIT_PENDING_EXCEPTION)) {
    1097       pthread_mutex_unlock(mach_exception_lock);
    1098       SEM_WAIT_FOREVER(tcr->suspend);
    1099       pthread_mutex_lock(mach_exception_lock);
    1100       CLR_TCR_FLAG(tcr,TCR_FLAG_BIT_SUSPEND_ACK_PENDING);
    1101       return true;
    1102     } else {
    1103       /* We don't know for sure whether or not there's an exception
    1104          pending on the thread.  Wait for as short a time as possible,
    1105          but try to give some CPU time to the target thread and/or the
    1106          exception thread.
    1107       */
    1108 
    1109       mach_timespec_t q = {0,1};
    1110       kern_return_t kret;
    1111      
    1112       kret = semaphore_timedwait((SEMAPHORE)(natural)(tcr->suspend),q);
    1113       if (kret == KERN_SUCCESS) {
    1114         tcr->flags &= ~(1<<TCR_FLAG_BIT_SUSPEND_ACK_PENDING);
    1115         return true;
    1116       }
    1117       return false;
    1118     }
    1119   }
    1120 #endif
    11211077}
    11221078
     
    11321088  LOCK(lisp_global(TCR_AREA_LOCK),current);
    11331089#ifdef DARWIN
     1090#if USE_MACH_EXCEPTION_LOCK
    11341091  if (use_mach_exception_handling) {
    11351092    pthread_mutex_lock(mach_exception_lock);
    11361093  }
     1094#endif
    11371095#endif
    11381096  suspended = suspend_tcr(tcr);
     
    11411099  }
    11421100#ifdef DARWIN
     1101#if USE_MACH_EXCEPTION_LOCK
    11431102  if (use_mach_exception_handling) {
    11441103    pthread_mutex_unlock(mach_exception_lock);
    11451104  }
     1105#endif
    11461106#endif
    11471107  UNLOCK(lisp_global(TCR_AREA_LOCK),current);
     
    12751235  LOCK(lisp_global(TCR_AREA_LOCK), current);
    12761236#ifdef DARWIN
     1237#if USE_MACH_EXCEPTION_LOCK
    12771238  if (for_gc && use_mach_exception_handling) {
    12781239#if SUSPEND_RESUME_VERBOSE
     
    12811242    pthread_mutex_lock(mach_exception_lock);
    12821243  }
     1244#endif
    12831245#endif
    12841246  for (other = current->next; other != current; other = other->next) {
     
    13411303  free_freed_tcrs();
    13421304#ifdef DARWIN
     1305#if USE_MACH_EXCEPTION_LOCK
    13431306  if (for_gc && use_mach_exception_handling) {
    13441307#if SUSPEND_RESUME_VERBOSE
     
    13471310    pthread_mutex_unlock(mach_exception_lock);
    13481311  }
     1312#endif
    13491313#endif
    13501314
Note: See TracChangeset for help on using the changeset viewer.