void petabricks::DistributedGC::onRecv(const void* buf, size_t s, int) { const EncodedPtr* begin = reinterpret_cast<const EncodedPtr*>(buf); const EncodedPtr* end = begin+(s/sizeof(EncodedPtr)); std::set<EncodedPtr> remoteDead(begin, end); #ifdef DEBUG int deletecount = 0; #endif RemoteObjectList::iterator i; for(i=_objectsMaybeDead.begin(); i!=_objectsMaybeDead.end(); ++i) { if(remoteDead.find(host()->asEncoded(i->asPtr())) == remoteDead.end()) { _objects.push_back(*i); }else{ #ifdef DEBUG ++deletecount; JASSERT(canDeleteLocal(*(*i))); #endif } } #ifdef DEBUG JTRACE("DistributedGC deleting objects")(deletecount); #endif _objectsMaybeDead.clear(); finishup(); }
void petabricks::DistributedGC::onNotify(int stage) { if(stage == FLUSH_MSGS) { remoteNotify(DO_SCAN); }else if(stage == DO_SCAN) { std::vector<EncodedPtr> response; scan(response); if(! response.empty() ) { unlock(); send(&response[0], sizeof(EncodedPtr)*response.size()); lock(); }else{ remoteNotify(ABORT_GC); finishup(); } }else if(stage == ABORT_GC) { finishup(); }else UNIMPLEMENTED(); }
void dmtcp::ConnectionRewirer::onConnect ( const jalib::JSocket& sock, const struct sockaddr* /*remoteAddr*/,socklen_t /*remoteLen*/ ) { jalib::JSocket remote = sock; DmtcpMessage msg; msg.poison(); remote >> msg; msg.assertValid(); JASSERT ( msg.type == DMT_RESTORE_RECONNECTED ) ( msg.type ).Text ( "unexpected message" ); iterator i = _pendingIncoming.find ( msg.restorePid ); JASSERT ( i != _pendingIncoming.end() ) ( msg.restorePid ) .Text ( "got unexpected incoming restore request" ); const dmtcp::vector<int>& fds = i->second; JASSERT ( fds.size() > 0 ); int fd0 = fds[0]; remote.changeFd ( fd0 ); JTRACE ( "restoring incoming connection" ) ( msg.restorePid ) ( fd0 ) ( fds.size() ); for ( size_t i = 1; i<fds.size(); ++i ) { JTRACE ( "restoring extra fd" ) ( fd0 ) ( fds[i] ); JASSERT ( _real_dup2 ( fd0,fds[i] ) == fds[i] ) ( fd0 ) ( fds[i] ) ( msg.restorePid ) .Text ( "dup2() failed" ); } _pendingIncoming.erase ( i ); if ( pendingCount() ==0 ) finishup(); #ifdef DEBUG else debugPrint(); #endif }
int _start (char *image) { char debugb[4]; int fd; uLong debugc, sts; OZ_Handle h_logname, h_table; /* Open stdin/stdout/stderr files */ fd = open ("OZ_INPUT", O_RDONLY); if (fd != STDIN_FILENO) { oz_sys_io_fs_printerror ("oz_crtl_start: STDIN opened as fileno %d, errno %d", fd, errno); return (-1); } fd = open ("OZ_OUTPUT", O_WRONLY | O_APPEND); if (fd != STDOUT_FILENO) { oz_sys_io_fs_printerror ("oz_crtl_start: STDOUT opened as fileno %d, errno %d", fd, errno); return (-1); } fd = open ("OZ_ERROR", O_WRONLY | O_APPEND); if (fd != STDERR_FILENO) { oz_sys_io_fs_printerror ("oz_crtl_start: STDERR opened as fileno %d, errno %d", fd, errno); return (-1); } /* Open them as streams now */ stdin = fdopen (STDIN_FILENO, "r"); if (stdin == NULL) { oz_sys_io_fs_printerror ("oz_crtl_start: stdin open error %d\n", errno); return (-1); } stdout = fdopen (STDOUT_FILENO, "w+"); if (stdout == NULL) { oz_sys_io_fs_printerror ("oz_crtl_start: stdout open error %d\n", errno); return (-1); } stderr = fdopen (STDERR_FILENO, "w+"); if (stderr == NULL) { oz_sys_io_fs_printerror ("oz_crtl_start: stderr open error %d\n", errno); return (-1); } setvbuf (stderr, NULL, _IONBF, 0); /* Get OZ_DEBUG to see if the debugger should be used */ debugb[0] = 0; sts = oz_sys_logname_lookup (0, OZ_PROCMODE_USR, oz_s_logname_defaulttables, NULL, NULL, NULL, &h_table); if (sts != OZ_SUCCESS) { oz_sys_io_fs_printerror ("oz_crtl_start: error %u looking up default tables (%s)\n", sts, oz_s_logname_defaulttables); return (sts); } sts = oz_sys_logname_lookup (h_table, OZ_PROCMODE_USR, "OZ_DEBUG", NULL, NULL, &debugc, &h_logname); if ((sts != OZ_SUCCESS) && (sts != OZ_NOLOGNAME)) { oz_sys_io_fs_printerror ("oz_crtl_start: error %u looking up OZ_DEBUG\n", sts); return (sts); } if (sts == OZ_SUCCESS) { if (debugc > 0) { sts = oz_sys_logname_getval (h_logname, 0, NULL, sizeof debugb, debugb, NULL, NULL, 0, NULL); if (sts != OZ_SUCCESS) { oz_sys_io_fs_printerror ("oz_crtl_start: error %u getting OZ_DEBUG string\n", sts); return (sts); } } oz_sys_handle_release (OZ_PROCMODE_KNL, h_logname); } oz_sys_handle_release (OZ_PROCMODE_KNL, h_table); /* Call the debugger init routine to handle the rest */ if (debugb[0] & 1) { sts = oz_usr_debug_init (finishup, image); } else { sts = finishup (image); } return (sts); }
/*---------------------------------------------------------------------+ | main () | | ==================================================================== | | | | Function: Main program | | | +---------------------------------------------------------------------*/ int main(int argc, char **argv) { long runseconds, /* number of seconds to run */ start_time; /* time at start of driver */ int current_priority, /* current priority level for nice */ workslots, /* number of free workslots */ long_term_slot_total, /* workslots for long-term processes */ short_term_slot_total; /* workslots for short-term */ /* * Parse command line arguments & printer program header... */ parse_args(argc, argv); printf("Scheduler Testsuite Program\n\n"); fflush(stdout); /* * Calculate number of seconds to run, then print out start info */ runseconds = (long)(execution_time * 60.0 * 60.0); start_time = time(NULL); startup(start_time); /* * Calculate available workslots, long-term, and short-term slots */ workslots = available_user_process_slots() * stress_percent; long_term_slot_total = workslots / 2; if (debug) { printf("available slots: %d\n", available_user_process_slots()); printf("workslots available: %d\n", workslots); printf("stress_percent: %f\n", stress_percent); printf("run-hours: %f (hrs)\n", execution_time); printf("runseconds: %ld (sec)\n", runseconds); } /* * Run the first set of tests with an average priority */ perform_throughput_tests((MAX_PRI + MIN_PRI) / 2); fflush(stdout); /* * Start the long-term testcases running */ start_long_term_testcases(long_term_slot_total, argv[2]); short_term_slot_total = workslots / 2; fflush(stdout); /* * Loop while there is still time */ current_priority = MAX_PRI; while ((time(0) - start_time) < runseconds) { if (debug) printf("current priority: %d\n", current_priority); if (debug) printf("starting short term tests\n"); start_short_term_testcases(short_term_slot_total, stress_percent, current_priority); fflush(stdout); perform_throughput_tests(current_priority); fflush(stdout); if (debug) printf("killing short term tests\n"); kill_short_term_testcases(); fflush(stdout); if (current_priority + PRIINC > MIN_PRI) current_priority = MAX_PRI; else current_priority += PRIINC; } /* * Exit with success... */ finishup(start_time); printf("\nsuccessful!\n"); fflush(stdout); return (0); }
void dmtcp::ConnectionRewirer::onData ( jalib::JReaderInterface* sock ) { JASSERT ( sock->bytesRead() == sizeof ( DmtcpMessage ) ) ( sock->bytesRead() ) ( sizeof ( DmtcpMessage ) ); DmtcpMessage& msg = * ( DmtcpMessage* ) sock->buffer(); msg.assertValid(); if ( msg.type == DMT_FORCE_RESTART ) { JTRACE ( "got DMT_FORCE_RESTART, exiting ConnectionRewirer" ) ( _pendingOutgoing.size() ) ( _pendingIncoming.size() ); _pendingIncoming.clear(); _pendingOutgoing.clear(); finishup(); return; } JASSERT ( msg.type==DMT_RESTORE_WAITING ) ( msg.type ).Text ( "unexpected message" ); // Find returns iterator 'i' w/ 0 or more elts, with first elt matching key. iterator i = _pendingOutgoing.find ( msg.restorePid ); if ( i == _pendingOutgoing.end() ) { // 'i' is an iterator over 0 elements. JTRACE ( "got RESTORE_WAITING MESSAGE [not used]" ) ( msg.restorePid ) ( _pendingOutgoing.size() ) ( _pendingIncoming.size() ); } else { // 'i' is an iterator over 1 element. JTRACE ( "got RESTORE_WAITING MESSAGE, reconnecting..." ) ( msg.restorePid ) ( msg.restorePort ) ( msg.restoreAddrlen ) ( _pendingOutgoing.size() ) ( _pendingIncoming.size() ); const dmtcp::vector<int>& fds = i->second; JASSERT ( fds.size() > 0 ); int fd0 = fds[0]; jalib::JSocket remote = jalib::JSocket::Create(); remote.changeFd ( fd0 ); errno = 0; JASSERT ( remote.connect ( ( sockaddr* ) &msg.restoreAddr,msg.restoreAddrlen,msg.restorePort ) ) ( msg.restorePid ) ( msg.restorePort ) ( JASSERT_ERRNO ) .Text ( "failed to restore connection" ); { DmtcpMessage peerMsg; peerMsg.type = DMT_RESTORE_RECONNECTED; peerMsg.restorePid = msg.restorePid; addWrite ( new jalib::JChunkWriter ( remote, ( char* ) &peerMsg,sizeof ( peerMsg ) ) ); } for ( size_t n = 1; n<fds.size(); ++n ) { JTRACE ( "restoring extra fd" ) ( fd0 ) ( fds[n] ); JASSERT ( _real_dup2 ( fd0,fds[n] ) == fds[n] ) ( fd0 ) ( fds[n] ) ( msg.restorePid ) .Text ( "dup2() failed" ); } _pendingOutgoing.erase ( i ); } if ( pendingCount() ==0 ) finishup(); #ifdef DEBUG else debugPrint(); #endif }