Created
September 21, 2010 20:33
-
-
Save koush/590473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int GC_suspend_all() | |
{ | |
int n_live_threads = 0; | |
int i; | |
GC_thread p; | |
int result; | |
pthread_t my_thread = pthread_self(); | |
GC_stopping_thread = my_thread; /* debugging only. */ | |
GC_stopping_pid = getpid(); /* debugging only. */ | |
for (i = 0; i < THREAD_TABLE_SZ; i++) { | |
for (p = GC_threads[i]; p != 0; p = p -> next) { | |
if (p -> id != my_thread) { | |
if (p -> flags & FINISHED) continue; | |
if (p -> stop_info.last_stop_count == GC_stop_count) continue; | |
if (p -> thread_blocked) /* Will wait */ continue; | |
n_live_threads++; | |
#if DEBUG_THREADS | |
GC_printf1("Sending suspend signal to 0x%lx\n", p -> id); | |
#endif | |
result = pthread_kill(p -> id, SIG_SUSPEND); | |
switch(result) { | |
case ESRCH: | |
/* Not really there anymore. Possible? */ | |
n_live_threads--; | |
break; | |
case 0: | |
break; | |
default: | |
ABORT("pthread_kill failed"); | |
} | |
} | |
} | |
} | |
return n_live_threads; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment