Changeset 471
- Timestamp:
- Feb 6, 2004, 11:26:36 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/lisp-kernel/thread_manager.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/lisp-kernel/thread_manager.c
r454 r471 435 435 tcr->tlb_pointer[i] = (LispObj) no_thread_local_binding_marker; 436 436 } 437 437 tcr->shutdown_count = PTHREAD_DESTRUCTOR_ITERATIONS; 438 438 return tcr; 439 439 } … … 456 456 } 457 457 458 if (tcr->flags & (1<<TCR_FLAG_BIT_SHUTDOWN_REQUEST)) { 459 tcr->flags &= ~(1<<TCR_FLAG_BIT_SHUTDOWN_REQUEST); 460 458 if (--(tcr->shutdown_count) == 0) { 459 #ifdef DEBUG_THREAD_CLEANUP 460 fprintf(stderr, "\nprocessing final shutdown request for pthread 0x%x tcr 0x%x", pthread_self(), tcr); 461 #endif 461 462 #ifdef DARWIN 462 463 darwin_exception_cleanup(tcr); … … 484 485 tcr->osid = 0; 485 486 } else { 486 tcr->flags |= (1<<TCR_FLAG_BIT_SHUTDOWN_REQUEST);487 487 tsd_set(lisp_global(TCR_KEY), tcr); 488 #ifdef DEBUG_THREAD_CLEANUP 489 fprintf(stderr, "\nprocessing early shutdown request for pthread 0x%x tcr 0x%x, tsd = 0x%x", 490 pthread_self(), tcr, tsd_get(lisp_global(TCR_KEY))); 491 #endif 488 492 } 489 493 } … … 725 729 current->flags |= (1<<TCR_FLAG_BIT_FOREIGN); 726 730 register_thread_tcr(current); 727 731 #ifdef DEBUG_TCR_CREATION 732 fprintf(stderr, "\ncreating TCR for pthread 0x%x", pthread_self()); 733 #endif 728 734 current->vs_area->active -= 4; 729 735 *(--current->save_vsp) = lisp_nil; … … 746 752 int suspend_count = atomic_incf(&(tcr->suspend_count)); 747 753 if (suspend_count == 1) { 748 pthread_kill((pthread_t)tcr->osid, thread_suspend_signal); 749 SEM_WAIT(tcr->suspend); 750 } 751 return suspend_count == 1; 754 if (pthread_kill((pthread_t)tcr->osid, thread_suspend_signal) == 0) { 755 SEM_WAIT(tcr->suspend); 756 } else { 757 /* A problem using pthread_kill. On Darwin, this can happen 758 if the thread has had its signal mask surgically removed 759 by pthread_exit. If the native (Mach) thread can be suspended, 760 do that and return true; otherwise, flag the tcr as belonging 761 to a dead thread by setting tcr->osid to 0. 762 */ 763 #ifdef DARWIN 764 if (mach_suspend_tcr(tcr)) { 765 tcr->flags |= TCR_FLAG_BIT_ALT_SUSPEND; 766 return true; 767 } 768 #endif 769 tcr->osid = 0; 770 return false; 771 } 772 return true; 773 } 774 return false; 752 775 } 753 776 … … 770 793 int suspend_count = atomic_decf(&(tcr->suspend_count)); 771 794 if (suspend_count == 0) { 795 #ifdef DARWIN 796 if (tcr->flags & TCR_FLAG_BIT_ALT_SUSPEND) { 797 tcr->flags &= ~TCR_FLAG_BIT_ALT_SUSPEND; 798 mach_resume_tcr(tcr); 799 return true; 800 } 801 #endif 772 802 pthread_kill((pthread_t)tcr->osid, thread_resume_signal); 773 } 774 return (suspend_count == 0); 803 return true; 804 } 805 return false; 775 806 } 776 807 … … 799 830 LOCK(lisp_global(TCR_LOCK), current); 800 831 for (other = current->next; other != current; other = other->next) { 801 if ( other->osid != 0) {832 if ((other->osid != 0)) { 802 833 suspend_tcr(other); 834 if (other->osid == 0) { 835 dead_tcr_count++; 836 } 803 837 } else { 804 838 dead_tcr_count++; … … 809 843 for (other = current->next; other != current; other = next) { 810 844 next = other->next; 811 if ( other->osid == 0){845 if ((other->osid == 0)) { 812 846 dequeue_tcr(other); 813 847 free(other);
Note:
See TracChangeset
for help on using the changeset viewer.
