void sdlout_drain (void) { AUDDBG ("Draining.\n"); pthread_mutex_lock (& sdlout_mutex); check_started (); while (buffer_data_len) pthread_cond_wait (& sdlout_cond, & sdlout_mutex); pthread_mutex_unlock (& sdlout_mutex); }
/* * call-seq: * Byebug.thread_context(thread) -> context * * Returns context of the thread passed as an argument. */ static VALUE Thread_context(VALUE self, VALUE thread) { VALUE context; UNUSED(self); check_started(); thread_context_lookup(thread, &context); return context; }
/* * call-seq: * Byebug.current_context -> context * * Returns the current context. * <i>Note:</i> Byebug.current_context.thread == Thread.current */ static VALUE Current_context(VALUE self) { VALUE context; UNUSED(self); check_started(); thread_context_lookup(rb_thread_current(), &context); return context; }
void sdlout_period_wait (void) { pthread_mutex_lock (& sdlout_mutex); while (buffer_data_len == buffer_size) { if (! paused_flag) check_started (); pthread_cond_wait (& sdlout_cond, & sdlout_mutex); } pthread_mutex_unlock (& sdlout_mutex); }
/* * call-seq: * Byebug.contexts -> array * * Returns an array of all contexts. */ static VALUE Contexts(VALUE self) { volatile VALUE list; volatile VALUE new_list; VALUE context; threads_table_t *t_tbl; debug_context_t *dc; int i; UNUSED(self); check_started(); new_list = rb_ary_new(); list = rb_funcall(rb_cThread, rb_intern("list"), 0); for (i = 0; i < RARRAY_LENINT(list); i++) { VALUE thread = rb_ary_entry(list, i); thread_context_lookup(thread, &context); rb_ary_push(new_list, context); } Data_Get_Struct(threads, threads_table_t, t_tbl); st_clear(t_tbl->tbl); for (i = 0; i < RARRAY_LENINT(new_list); i++) { context = rb_ary_entry(new_list, i); Data_Get_Struct(context, debug_context_t, dc); st_insert(t_tbl->tbl, dc->thread, context); } return new_list; }
void mpijob::run_child() { #ifndef __WINDOWS__ // check that this child hasn't been finished by others if (check_finished()) { cout << "child " << conf.get_name() << " is already finished, do nothing." << endl; return ; // already finished, do nothing } // start timer t.start(); string cmd, log, errlog; log << "out_" << conf.get_name() << ".log"; errlog << "out_" << conf.get_name() << ".errlog"; // prepare command cmd << "cd " << outdir << " && echo \"job=" << conf.get_name(); if (conf.exists("meta_conf_shortname")) cmd << " meta_conf_shortname=" << conf.get_string("meta_conf_shortname"); // not finished, check if it has been started in the past if (check_started()) { cout << "child " << conf.get_name() << " is already started but not finished, resuming." << endl; figure_resume_out(); if (conf.exists("retrain_iteration") && conf.exists("retrain_weights") && conf.exists("retrain")) { // add retrain params at the end of job's conf ofstream of(confname.c_str(), ios_base::app); if (!of) eblerror("failed to open conf for appending retrain params: " << confname); of << endl << " retrain_iteration=" << conf.get_string("retrain_iteration") << endl << " retrain_weights=" << conf.get_string("retrain_weights") << endl << " retrain=" << conf.get_string("retrain") << endl; of.close(); } } // set classe filename if defined if (rconf.exists("train") || rconf.exists("train_classes")) { string classesname = conf.get_output_dir(); if (rconf.exists("train")) classesname << "/" << rconf.get_string("train"); else if (rconf.exists("train_classes")) classesname << "/" << rconf.get_string("train_classes"); classesname << CLASSES_NAME << MATRIX_EXTENSION; cmd << " classes=" << classesname; } // set rest of command cmd << " config=" << confname << "\" >> " << log << " && ((" << exe << " " << confname << " 3>&1 1>&2 2>&3 | tee /dev/tty | tee -a " << errlog << ") 3>&1 1>&2 2>&3) >> " << log << " 2>&1 && exit 0"; // execute child cout << endl << "(mpi) Executing job " << basename(confname.c_str()) << " with cmd:" << endl << cmd << endl; int ret = std::system(cmd.c_str()); if (ret != 0) { cerr << "child command error: " << ret << endl; cerr << "WIFSIGNALED(" << ret << "): " << WIFSIGNALED(ret) << endl; cerr << "WTERMSIG(" << ret << "): " << WTERMSIG(ret) << endl; } #else eblerror("not implemented"); #endif }