* * Wait for all threads to finish restoring their context, then release them * all to continue on their way. * *****************************************************************************/
| 697 | * |
| 698 | *****************************************************************************/ |
| 699 | void |
| 700 | ThreadList::waitForAllRestored(Thread *thread) |
| 701 | { |
| 702 | if (thread == ckptThread) { |
| 703 | int i; |
| 704 | for (i = 0; i < numUserThreads; i++) { |
| 705 | sem_wait(&semNotifyCkptThread); |
| 706 | } |
| 707 | |
| 708 | // Now that all threads have been created, restore the signal handler. We |
| 709 | // need to do it before calling DmtcpWorker::postRestart() because that |
| 710 | // routine will invoke restart hooks for all plugins. Some of the plugins |
| 711 | // might perform tasks that could potentially generate a signal. For |
| 712 | // example, the timer plugin may restore a timer which will fire right away, |
| 713 | // and not having an appropriate signal handler could kill the process. |
| 714 | SigInfo::restoreSigHandlers(); |
| 715 | |
| 716 | JTRACE("before DmtcpWorker::postRestart()"); |
| 717 | |
| 718 | DmtcpWorker::postRestart(thread->ckptReadTime); |
| 719 | |
| 720 | JTRACE("after DmtcpWorker::postRestart()"); |
| 721 | |
| 722 | /* raise the signals which were pending for the entire process at the time |
| 723 | * of checkpoint. It is assumed that if a signal is pending for all threads |
| 724 | * including the ckpt-thread, then it was sent to the process as opposed to |
| 725 | * sent to individual threads. |
| 726 | */ |
| 727 | for (i = SIGRTMAX; i > 0; --i) { |
| 728 | if (sigismember(&sigpending_global, i) == 1) { |
| 729 | kill(getpid(), i); |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | // if this was last of all, wake everyone up |
| 734 | for (i = 0; i < numUserThreads; i++) { |
| 735 | sem_post(&semWaitForCkptThreadSignal); |
| 736 | } |
| 737 | } else { |
| 738 | sem_post(&semNotifyCkptThread); |
| 739 | sem_wait(&semWaitForCkptThreadSignal); |
| 740 | } |
| 741 | |
| 742 | PluginManager::eventHook(DMTCP_EVENT_THREAD_RESUME); |
| 743 | |
| 744 | Thread_RestoreSigState(thread); |
| 745 | |
| 746 | if (thread == motherofall) { |
| 747 | DMTCP_RESTART_PAUSE_WHILE(restartPauseLevel == 7); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | /***************************************************************************** |
| 752 | * |
nothing calls this directly
no test coverage detected