mirror of https://github.com/BOINC/boinc.git
- API: in boinc_exit(), release the lockfile only if
we're the main program (otherwise we didn't lock it in the first place, and a crash results). From Artyom Sharov. - scheduler: add support for the GCL simulator, which uses special versions of backend programs that use virtual time, and that wait for signals instead of sleep()ing. To compile: make clean configure CXXFLAGS="-DGCL_SIMULATOR" make svn path=/trunk/boinc/; revision=16036
This commit is contained in:
parent
e432bb1182
commit
0f8f9f3dab
|
@ -114,6 +114,9 @@ using std::vector;
|
|||
#include "sched_util.h"
|
||||
#include "sched_msgs.h"
|
||||
#include "hr_info.h"
|
||||
#ifdef GCL_SIMULATOR
|
||||
#include "gcl_simulator.h"
|
||||
#endif
|
||||
|
||||
#define DEFAULT_SLEEP_INTERVAL 5
|
||||
|
||||
|
@ -143,7 +146,6 @@ int napps;
|
|||
HR_INFO hr_info;
|
||||
bool using_hr;
|
||||
// true iff any app is using HR
|
||||
bool simulation = false;
|
||||
|
||||
void signal_handler(int) {
|
||||
log_messages.printf(MSG_NORMAL, "Signaled by simulator\n");
|
||||
|
@ -508,15 +510,16 @@ void feeder_loop() {
|
|||
bool action = scan_work_array(work_items);
|
||||
ssp->ready = true;
|
||||
if (!action) {
|
||||
if (simulation) {
|
||||
signal(SIGUSR2, signal_handler);
|
||||
pause();
|
||||
} else {
|
||||
log_messages.printf(MSG_DEBUG,
|
||||
"No action; sleeping %.2f sec\n", sleep_interval
|
||||
);
|
||||
boinc_sleep(sleep_interval);
|
||||
}
|
||||
#ifdef GCL_SIMULATOR
|
||||
log_messages.printf(MSG_DEBUG, "Waiting for signal\n");
|
||||
signal(SIGUSR2, simulator_signal_handler);
|
||||
pause();
|
||||
#else
|
||||
log_messages.printf(MSG_DEBUG,
|
||||
"No action; sleeping %.2f sec\n", sleep_interval
|
||||
);
|
||||
boinc_sleep(sleep_interval);
|
||||
#endif
|
||||
} else {
|
||||
if (config.job_size_matching) {
|
||||
update_stats();
|
||||
|
@ -653,8 +656,6 @@ int main(int argc, char** argv) {
|
|||
sprintf(mod_select_clause, "and workunit.id %% %d = %d ", n, j);
|
||||
} else if (!strcmp(argv[i], "-sleep_interval")) {
|
||||
sleep_interval = atof(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-simulator")) {
|
||||
simulation = true;
|
||||
} else {
|
||||
log_messages.printf(MSG_CRITICAL,
|
||||
"bad cmdline arg: %s\n", argv[i]
|
||||
|
|
|
@ -58,15 +58,13 @@ int HR_INFO::read_file() {
|
|||
double x;
|
||||
|
||||
for (i=1; i<HR_NTYPES; i++) {
|
||||
char* p = fgets(buf, sizeof(buf), f);
|
||||
if (!p) {
|
||||
fprintf(stderr, "missing delimiter line in HR info\n");
|
||||
if (!fgets(buf, sizeof(buf), f)) {
|
||||
fprintf(stderr, "unexpected EOF in HR info\n");
|
||||
exit(1);
|
||||
}
|
||||
for (j=0; j<hr_nclasses[i]; j++) {
|
||||
char* p = fgets(buf, sizeof(buf), f);
|
||||
if (!p) {
|
||||
fprintf(stderr, "missing data line in HR info");
|
||||
if (!fgets(buf, sizeof(buf), f)) {
|
||||
fprintf(stderr, "unexpected EOF in HR info");
|
||||
exit(1);
|
||||
}
|
||||
int n = sscanf(buf, "%d %lf", &jj, &x);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// A sample assimilator that:
|
||||
// 1) if success, copy the output file(s) to a directory
|
||||
// 2) if failure, append a message to an error log
|
||||
|
|
|
@ -292,4 +292,38 @@ int count_unsent_results(int& n, int appid) {
|
|||
|
||||
}
|
||||
|
||||
#ifdef GCL_SIMULATOR
|
||||
|
||||
void simulator_signal_handler(int signum){
|
||||
FILE *fsim;
|
||||
char currenttime[64];
|
||||
fsim = fopen("../simulator/sim_time.txt","r");
|
||||
if(fsim){
|
||||
fscanf(fsim, "%f", &simtime);
|
||||
fclose(fsim);
|
||||
}
|
||||
log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,
|
||||
"Invoked by the simulator at time %.0f... \n", simtime
|
||||
);
|
||||
}
|
||||
|
||||
int itime() {
|
||||
return (int) simtime;
|
||||
}
|
||||
|
||||
void continue_simulation(const char *daemonname){
|
||||
char daemonfile[64];
|
||||
sprintf(daemonfile,"../simulator/sim_%s",daemonname);
|
||||
FILE *fsimlok=fopen(strcat(daemonfile,".lok"),"w");
|
||||
if(fsimlok){
|
||||
fclose(fsimlok);
|
||||
FILE *fsim=fopen(strcat(daemonfile,".txt"),"w");
|
||||
if (fsim){
|
||||
fclose(fsim);
|
||||
}
|
||||
}
|
||||
remove(strcat(daemonfile,".lok"));
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *BOINC_RCSID_affa6ef1e4 = "$Id$";
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define SCHED_UTIL_H
|
||||
|
||||
#include "boinc_db.h"
|
||||
#include "util.h"
|
||||
|
||||
// "average credit" uses an exponential decay so that recent
|
||||
// activity is weighted more heavily.
|
||||
|
@ -77,4 +78,10 @@ extern double fpops_to_credit(double fpops, double intops);
|
|||
|
||||
extern int count_workunits(int&, const char* query);
|
||||
extern int count_unsent_results(int&, int appid);
|
||||
|
||||
#ifdef GCL_SIMULATOR
|
||||
extern void simulator_signal_handler(int signum);
|
||||
extern void continue_simulation(const char *daemonname);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,9 @@ using namespace std;
|
|||
#include "sched_config.h"
|
||||
#include "sched_util.h"
|
||||
#include "sched_msgs.h"
|
||||
#ifdef GCL_SIMULATOR
|
||||
#include "gcl_simulator.h"
|
||||
#endif
|
||||
|
||||
#define LOCKFILE "transitioner.out"
|
||||
#define PIDFILE "transitioner.pid"
|
||||
|
@ -60,7 +63,6 @@ R_RSA_PRIVATE_KEY key;
|
|||
int mod_n, mod_i;
|
||||
bool do_mod = false;
|
||||
bool one_pass = false;
|
||||
bool simulation = false;
|
||||
|
||||
void signal_handler(int) {
|
||||
log_messages.printf(MSG_NORMAL, "Signaled by simulator\n");
|
||||
|
@ -649,13 +651,14 @@ void main_loop() {
|
|||
log_messages.printf(MSG_DEBUG, "doing a pass\n");
|
||||
if (!do_pass()) {
|
||||
if (one_pass) break;
|
||||
if (simulation) {
|
||||
signal(SIGUSR2, signal_handler);
|
||||
pause();
|
||||
} else {
|
||||
log_messages.printf(MSG_DEBUG, "sleeping %d\n", SLEEP_INTERVAL);
|
||||
sleep(SLEEP_INTERVAL);
|
||||
}
|
||||
#ifdef GCL_SIMULATOR
|
||||
continue_simulation("transitioner");
|
||||
signal(SIGUSR2, simulator_signal_handler);
|
||||
pause();
|
||||
#else
|
||||
log_messages.printf(MSG_DEBUG, "sleeping %d\n", SLEEP_INTERVAL);
|
||||
sleep(SLEEP_INTERVAL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -674,8 +677,6 @@ int main(int argc, char** argv) {
|
|||
mod_n = atoi(argv[++i]);
|
||||
mod_i = atoi(argv[++i]);
|
||||
do_mod = true;
|
||||
} else if (!strcmp(argv[i], "-simulator")) {
|
||||
simulation = true;
|
||||
}
|
||||
}
|
||||
if (!one_pass) check_stop_daemons();
|
||||
|
|
|
@ -96,9 +96,10 @@ bool do_trickle_scan() {
|
|||
int main_loop(bool one_pass) {
|
||||
int retval;
|
||||
bool did_something;
|
||||
char buf[256];
|
||||
|
||||
retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
|
||||
retval = boinc_db.open(
|
||||
config.db_name, config.db_host, config.db_user, config.db_passwd
|
||||
);
|
||||
if (retval) {
|
||||
log_messages.printf(MSG_CRITICAL, "boinc_db.open failed: %d\n", retval);
|
||||
exit(1);
|
||||
|
|
|
@ -52,6 +52,9 @@ using namespace std;
|
|||
#include "sched_msgs.h"
|
||||
#include "validator.h"
|
||||
#include "validate_util.h"
|
||||
#ifdef GCL_SIMULATOR
|
||||
#include "gcl_simulator.h"
|
||||
#endif
|
||||
|
||||
#define LOCKFILE "validate.out"
|
||||
#define PIDFILE "validate.pid"
|
||||
|
@ -87,14 +90,8 @@ double max_claimed_credit = 0;
|
|||
bool grant_claimed_credit = false;
|
||||
bool update_credited_job = false;
|
||||
bool credit_from_wu = false;
|
||||
bool simulation = false;
|
||||
WORKUNIT* g_wup;
|
||||
|
||||
void signal_handler(int) {
|
||||
log_messages.printf(MSG_NORMAL, "Signaled by simulator\n");
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_unreplicated(WORKUNIT& wu) {
|
||||
return (wu.target_nresults == 1 && app.target_nresults > 1);
|
||||
}
|
||||
|
@ -660,12 +657,12 @@ int main_loop() {
|
|||
did_something = do_validate_scan();
|
||||
if (!did_something) {
|
||||
if (one_pass) break;
|
||||
if (simulation) {
|
||||
signal(SIGUSR2, signal_handler);
|
||||
pause();
|
||||
} else {
|
||||
sleep(sleep_interval);
|
||||
}
|
||||
#ifdef GCL_SIMULATOR
|
||||
signal(SIGUSR2, simulator_signal_handler);
|
||||
pause();
|
||||
#else
|
||||
sleep(sleep_interval);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -735,8 +732,6 @@ int main(int argc, char** argv) {
|
|||
update_credited_job = true;
|
||||
} else if (!strcmp(argv[i], "-credit_from_wu")) {
|
||||
credit_from_wu = true;
|
||||
} else if (!strcmp(argv[i], "-simulator")) {
|
||||
simulation = true;
|
||||
} else {
|
||||
fprintf(stderr, "Invalid option '%s'\nTry `%s --help` for more information\n", argv[i], argv[0]);
|
||||
log_messages.printf(MSG_CRITICAL, "unrecognized arg: %s\n", argv[i]);
|
||||
|
|
Loading…
Reference in New Issue