Created
October 9, 2016 19:23
-
-
Save deadtrickster/5a92841276f3d069b58f5cdd2128ec9c 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
/* stop all other threads by sending them SIG_STOP_FOR_GC */ | |
for(p=all_threads; p; p=p->next) { | |
gc_assert(p->os_thread != 0); | |
FSHOW_SIGNAL((stderr,"/gc_stop_the_world: thread=%lu, state=%x\n", | |
p->os_thread, thread_state(p))); | |
if((p!=th) && ((thread_state(p)==STATE_RUNNING))) { | |
FSHOW_SIGNAL((stderr,"/gc_stop_the_world: suspending thread %lu\n", | |
p->os_thread)); | |
/* We already hold all_thread_lock, P can become DEAD but | |
* cannot exit, ergo it's safe to use pthread_kill. */ | |
status=pthread_kill(p->os_thread,SIG_STOP_FOR_GC); | |
if (status==ESRCH) { | |
/* This thread has exited. */ | |
gc_assert(thread_state(p)==STATE_DEAD); | |
} else if (status) { | |
lose("cannot send suspend thread=%lu: %d, %s\n", | |
p->os_thread,status,strerror(status)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment