Changeset 470


Ignore:
Timestamp:
Feb 6, 2004, 11:24:17 AM (21 years ago)
Author:
Gary Byers
Message:

Provide mach_suspend_tcr(), mach_resume_tcr() so that threads can
be suspended between pthread_exit() and their actual termination.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lisp-kernel/lisp-exceptions.c

    r458 r470  
    26962696
    26972697
     2698/*
     2699  Only do this if pthread_kill indicated that the pthread isn't
     2700  listening to signals anymore, as can happen as soon as pthread_exit()
     2701  is called on Darwin.  The thread could still call out to lisp as it
     2702  is exiting, so we need another way to suspend it in this case.
     2703*/
     2704Boolean
     2705mach_suspend_tcr(TCR *tcr)
     2706{
     2707  mach_port_t mach_thread = (mach_port_t) tcr->native_thread_id;
     2708  kern_return_t status = thread_suspend(mach_thread);
     2709  struct ucontext *lss;
     2710 
     2711  if (status != KERN_SUCCESS) {
     2712    return false;
     2713  }
     2714  lock_acquire(mach_exception_lock_set, 0);
     2715  lss = create_thread_context_frame(mach_thread, NULL);
     2716  lss->uc_onstack = 0;
     2717  lss->uc_sigmask = (sigset_t) 0;
     2718  tcr->suspend_context = lss;
     2719  tcr->suspend_total++;
     2720  lock_release(mach_exception_lock_set, 0);
     2721  return true;
     2722}
     2723
     2724void
     2725mach_resume_tcr(TCR *tcr)
     2726{
     2727  ExceptionInformation *xp;
     2728  mach_port_t mach_thread = (mach_port_t)(tcr->native_thread_id);
     2729 
     2730  lock_acquire(mach_exception_lock_set, 0);
     2731  xp = tcr->suspend_context;
     2732  tcr->suspend_context = NULL;
     2733  restore_mach_thread_state(mach_thread, xp);
     2734  lock_release(mach_exception_lock_set,0);
     2735}
     2736
     2737
    26982738#endif
Note: See TracChangeset for help on using the changeset viewer.