Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dmtcp exitest r527 #5

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65 for DMTCP 1.1.4.
Expand Down
1 change: 1 addition & 0 deletions dmtcp/jalib/jsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ ssize_t jalib::JSocket::readAll ( char* buf, size_t len )
JWARNING ( retval >= 0 ) ( tmp_sockfd ) ( JASSERT_ERRNO ).Text ( "select() failed" );
return -1;
}
JTRACE("SELECT retval = -1")(strerror(errno));
}
else if ( retval )
{
Expand Down
15 changes: 14 additions & 1 deletion dmtcp/src/dmtcpworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@ void dmtcp::DmtcpWorker::CleanupWorker()
_coordinatorSocket.close();
}


void dmtcp::DmtcpWorker::interruptCkpthread()
{
while( pthread_mutex_trylock(&destroyDmtcpWorker) == EBUSY){
killCkpthread();
}
}

//called after user main()
dmtcp::DmtcpWorker::~DmtcpWorker()
{
Expand All @@ -393,7 +401,7 @@ dmtcp::DmtcpWorker::~DmtcpWorker()
*/
JTRACE ( "exit() in progress, disconnecting from dmtcp coordinator" );
_coordinatorSocket.close();
JASSERT(pthread_mutex_lock(&destroyDmtcpWorker)==0)(JASSERT_ERRNO);
interruptCkpthread();
}
CleanupWorker();
}
Expand Down Expand Up @@ -1019,3 +1027,8 @@ void __attribute__ ((weak)) dmtcp::initializeMtcpEngine()
{
JASSERT(false).Text("should not be called");
}

void __attribute__ ((weak)) dmtcp::killCkpthread()
{
JASSERT(false).Text("should not be called");
}
2 changes: 2 additions & 0 deletions dmtcp/src/dmtcpworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ namespace dmtcp
static void setExitInProgress() { _exitInProgress = true; };
static bool exitInProgress() { return _exitInProgress; };

void interruptCkpthread();

void connectToCoordinator(bool doHanshaking=true);
// np > -1 means it is restarting process that have np processes in its computation group
// np == -1 means it is new pure process, so coordinator needs to generate compGroup ID for it
Expand Down
10 changes: 10 additions & 0 deletions dmtcp/src/mtcpinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ extern "C"
void ( *write_ckpt_prefix ) ( int fd ),
void ( *write_tid_maps) ());
typedef int ( *t_mtcp_ok ) ( void );
typedef void ( *t_mtcp_kill_ckpthread ) ( void );
}

static void callbackSleepBetweenCheckpoint ( int sec )
Expand Down Expand Up @@ -202,6 +203,15 @@ void dmtcp::initializeMtcpEngine()
JTRACE ( "mtcp_init complete" ) ( UniquePid::checkpointFilename() );
}



void dmtcp::killCkpthread()
{
t_mtcp_kill_ckpthread kill_ckpthread =
(t_mtcp_kill_ckpthread) _get_mtcp_symbol( "kill_ckpthread" );
kill_ckpthread();
}

#ifdef PID_VIRTUALIZATION
struct ThreadArg {
int ( *fn ) ( void *arg );
Expand Down
1 change: 1 addition & 0 deletions dmtcp/src/mtcpinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace dmtcp
{

void initializeMtcpEngine();
void killCkpthread();

void shutdownMtcpEngineOnFork();

Expand Down
1 change: 1 addition & 0 deletions dmtcp/src/workerhijack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ void __attribute__ ((weak)) dmtcp::initializeMtcpEngine()
{
JASSERT(false).Text("should not be called");
}

dmtcp::DmtcpWorker& dmtcp::DmtcpWorker::instance() { return theInstance; }

33 changes: 32 additions & 1 deletion mtcp/mtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,25 @@ int mtcp_no (void)
}
}
}


void kill_ckpthread (void)
{
int tid;
Thread *thread;

lock_threads ();
for (thread = threads; thread != NULL; thread = thread -> next) {
if ( mtcp_state_value(&thread -> state) == ST_CKPNTHREAD ) {
unlk_threads ();
printf("\n\n\nKill checkpinthread, tid=%d\n\n\n",thread->tid);
mtcp_sys_kernel_tkill(thread -> tid, STOPSIGNAL);
return;
}
}
unlk_threads ();
}


/********************************************************************************************************************************/
/* */
Expand Down Expand Up @@ -1180,6 +1199,7 @@ static void *checkpointhread (void *dummy)
ckpthread = getcurrenthread ();
save_sig_state (ckpthread);
save_tls_state (ckpthread);

/* Release user thread after we've initialized. */
sem_post(&sem_start);
if (getcontext (&(ckpthread -> savctx)) < 0) mtcp_abort ();
Expand Down Expand Up @@ -2139,12 +2159,19 @@ static void stopthisthread (int signum)
#define STDERR_FD 826
#define LOG_FD 826



DPRINTF (("mtcp stopthisthread*: tid %d returns to %p\n",
mtcp_sys_kernel_gettid (), __builtin_return_address (0)));

setup_sig_handler (); // re-establish in case of another STOPSIGNAL so we don't abort by default

thread = getcurrenthread (); // see which thread this is

if( mtcp_state_value(&thread -> state) == ST_CKPNTHREAD ){
return ;
}

if (0 && thread == motherofall) {
void *buffer[BT_SIZE];
int nptrs;
Expand Down Expand Up @@ -2308,7 +2335,6 @@ static void wait_for_all_restored (void)
/********************************************************************************************************************************/

static void save_sig_state (Thread *thisthread)

{
int i;
sigset_t blockall;
Expand All @@ -2331,6 +2357,11 @@ static void save_sig_state (Thread *thisthread)
}
}
}

sigdelset(&blockall,STOPSIGNAL);
if (_real_sigprocmask (SIG_SETMASK, &blockall, &(thisthread -> sigblockmask)) < 0) {
mtcp_abort ();
}
}

/********************************************************************************************************************************/
Expand Down