Changeset 14658


Ignore:
Timestamp:
Feb 24, 2011, 12:10:12 PM (8 years ago)
Author:
gb
Message:

Try to fix Mach kernel thread lossage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/thread_manager.c

    r14619 r14658  
    13261326
    13271327  area *vs, *ts, *cs;
     1328#ifdef DARWIN
     1329  mach_port_t kernel_thread;
     1330#endif
    13281331 
    13291332  if (current == NULL) {
     
    13421345#ifdef DARWIN
    13431346    darwin_exception_cleanup(tcr);
     1347    kernel_thread = (mach_port_t) (uint32_t)(natural)( TCR_AUX(tcr)->native_thread_id);
    13441348#endif
    13451349    LOCK(lisp_global(TCR_AREA_LOCK),current);
     
    14111415#endif
    14121416    UNLOCK(lisp_global(TCR_AREA_LOCK),current);
     1417#ifdef DARWIN
     1418    {
     1419      mach_port_urefs_t nrefs;
     1420      ipc_space_t task = mach_task_self();
     1421
     1422      if (mach_port_get_refs(task,kernel_thread,MACH_PORT_RIGHT_SEND,&nrefs) == KERN_SUCCESS) {
     1423        if (nrefs > 1) {
     1424          mach_port_mod_refs(task,kernel_thread,MACH_PORT_RIGHT_SEND,-(nrefs-1));
     1425        }
     1426      }
     1427    }
     1428#endif
    14131429  } else {
    14141430    tsd_set(lisp_global(TCR_KEY), TCR_TO_TSD(tcr));
     
    14541470#endif
    14551471#ifdef DARWIN
    1456           mach_thread_self()
     1472          pthread_mach_thread_np(pthread_self())
    14571473#endif
    14581474#ifdef FREEBSD
     
    26622678
    26632679
     2680#ifdef DARWIN
     2681/* For debugging. */
     2682int
     2683mach_port_send_refs(mach_port_t port)
     2684{
     2685  mach_port_urefs_t nrefs;
     2686  ipc_space_t task = mach_task_self();
     2687 
     2688  if (mach_port_get_refs(task,port,MACH_PORT_RIGHT_SEND,&nrefs) == KERN_SUCCESS) {
     2689    return nrefs;
     2690  }
     2691  return -1;
     2692}
     2693#endif
     2694
Note: See TracChangeset for help on using the changeset viewer.