diff --git a/api/x_opengl.C b/api/x_opengl.C index 1bf516afc0..991f08de87 100644 --- a/api/x_opengl.C +++ b/api/x_opengl.C @@ -21,7 +21,6 @@ static int acked_graphics_mode; static int xpos = 100, ypos = 100; static int clicked_button; static int win=0; -extern int userclose; extern void graphics_thread_init(); static void set_mode(int mode); @@ -68,22 +67,6 @@ void keyboardD(unsigned char key, int x, int y) { } } -#if 0 -void onIdle(){ - static double oldTime = 0; - double currentTime = dtime(); - - if (userclose == 1){ - userclose = 0; - set_mode(MODE_HIDE_GRAPHICS); - } - if (currentTime - oldTime > .001){ - timer_handler(); - oldTime = currentTime; - } -} -#endif - static void maybe_render() { int width, height; if (visible && (current_graphics_mode != MODE_HIDE_GRAPHICS)) { @@ -106,9 +89,13 @@ static void close_func() { static void make_new_window(int mode){ char* args[] = {"foobar", 0}; int one=1; + static bool first = false; if (mode == MODE_WINDOW || mode == MODE_FULLSCREEN){ - glutInit(&one, args); + if (first) { + glutInit(&one, args); + first = false; + } glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowPosition(xpos, ypos); glutInitWindowSize(600, 400); @@ -167,12 +154,6 @@ static void timer_handler(int) { char buf[MSG_CHANNEL_SIZE]; GRAPHICS_MSG m; -#if 0 - if (userclose) { - close_func(); - userclose = false; - } -#endif int new_mode; if (app_client_shm) { if (app_client_shm->shm->graphics_request.get_msg(buf)) { @@ -221,11 +202,6 @@ void xwin_graphics_event_loop() { graphics_thread = pthread_self(); if (boinc_is_standalone()) { set_mode(MODE_WINDOW); -#if 0 - if (userclose) { - return; - } -#endif } else { wait_for_initial_message(); timer_handler(0); @@ -233,8 +209,7 @@ void xwin_graphics_event_loop() { } int retval = setjmp(jbuf); if (retval) { - fprintf(stderr, "graphics thread restarted\n"); - fflush(stderr); + //fprintf(stderr, "graphics thread restarted\n"); fflush(stderr); set_mode(MODE_HIDE_GRAPHICS); } glutTimerFunc(TIMER_INTERVAL_MSEC, timer_handler, 0); diff --git a/checkin_notes b/checkin_notes index 83741b630e..d47857da61 100755 --- a/checkin_notes +++ b/checkin_notes @@ -19819,3 +19819,20 @@ David 18 Nov 2004 team_display.php team_email_lsit.php top_*.php + +David 18 Nov 2004 + - UNIX app graphics: only call glutInit() once (avoid error msg) + - UNIX: if app exits with external signal, restart it + - check_suspend_activities(), check_suspend_network(): + don't do anything more than once every 5 seconds + - call do_something() every 0.1 second, + to improve response time to GUI RPCs + + api/ + x_opengl.C + client/ + app_control.C + app_graphics.C + client_state.C,h + cs_prefs.C + main.C diff --git a/client/app_control.C b/client/app_control.C index ac1afd828f..02257b596a 100644 --- a/client/app_control.C +++ b/client/app_control.C @@ -276,16 +276,11 @@ bool ACTIVE_TASK::handle_exited_app(int stat) { // The process looks like it exited normally // but there's no "finish file". // Assume it was externally killed, - // and just leave it there - // (assume user is about to exit core client) + // and arrange for it to get restarted. // -#if 0 - state = PROCESS_IN_LIMBO; -#else scheduler_state = CPU_SCHED_PREEMPTED; state = PROCESS_UNINITIALIZED; detach_and_destroy_shmem(); -#endif limbo_message(*this); return true; } @@ -300,14 +295,15 @@ bool ACTIVE_TASK::handle_exited_app(int stat) { // if the process was externally killed, allow it to restart. // - switch(got_signal) { + switch (got_signal) { case SIGHUP: case SIGINT: case SIGQUIT: case SIGKILL: case SIGTERM: case SIGSTOP: - state = PROCESS_IN_LIMBO; + scheduler_state = CPU_SCHED_PREEMPTED; + state = PROCESS_UNINITIALIZED; limbo_message(*this); return true; } diff --git a/client/app_graphics.C b/client/app_graphics.C index 413394697f..690a36521c 100644 --- a/client/app_graphics.C +++ b/client/app_graphics.C @@ -64,7 +64,7 @@ void ACTIVE_TASK::check_graphics_mode_ack() { if (!app_client_shm.shm) return; if (app_client_shm.shm->graphics_reply.get_msg(buf)) { app_client_shm.decode_graphics_msg(buf, gm); - BOINCTRACE("got graphics ack %s for %s\n", buf, result->name); + //BOINCTRACE("got graphics ack %s for %s\n", buf, result->name); if (gm.mode != MODE_REREAD_PREFS) { graphics_mode_acked = gm.mode; } @@ -105,7 +105,7 @@ void ACTIVE_TASK_SET::save_app_modes() { atp->graphics_mode_acked = MODE_HIDE_GRAPHICS; } atp->graphics_mode_before_ss = atp->graphics_mode_acked; - BOINCTRACE("saved mode %d\n", atp->graphics_mode_acked); + //BOINCTRACE("saved mode %d\n", atp->graphics_mode_acked); } } @@ -186,11 +186,11 @@ ACTIVE_TASK* CLIENT_STATE::get_next_graphics_capable_app() { best_atp = atp; } if (best_atp) { - BOINCTRACE("chose SS: %s\n", best_atp->result->name); - return atp; - } + //BOINCTRACE("chose SS: %s\n", best_atp->result->name); + return atp; + } } } - BOINCTRACE("no SS to choose\n"); + //BOINCTRACE("no SS to choose\n"); return NULL; } diff --git a/client/client_state.C b/client/client_state.C index 2394d86a79..53bc79a667 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -342,7 +342,7 @@ bool CLIENT_STATE::do_something(double now) { start_cpu_benchmarks(); } - check_suspend_activities(reason); + check_suspend_activities(now, reason); if (reason) { if (!activities_suspended) { suspend_activities(reason); @@ -367,7 +367,7 @@ bool CLIENT_STATE::do_something(double now) { return gui_rpcs.poll(dtime()); } - check_suspend_network(reason); + check_suspend_network(now, reason); if (reason) { if (!network_suspended) { suspend_network(reason); diff --git a/client/client_state.h b/client/client_state.h index 57fa83554d..f6a9f638c6 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -186,7 +186,13 @@ private: // --------------- cs_apps.C: public: bool must_schedule_cpus; - // set when a result is newly runnable or finished + // Reschedule CPUs ASAP. Set when: + // - core client starts (CS::init()) + // - an app exits (ATS::check_app_exited()) + // - a result's input files finish downloading (CS::update_results()) + // - an app fails to start (CS::schedule_cpus()) + // - any project op is done via RPC (suspend/resume) + // - any result op is done via RPC (suspend/resume) int restart_tasks(); int quit_activities(); void set_ncpus(); @@ -238,10 +244,10 @@ public: int allowed_disk_usage(double&); int allowed_project_disk_usage(double&); private: - void check_suspend_activities(int&); + void check_suspend_activities(double, int&); int suspend_activities(int reason); int resume_activities(); - void check_suspend_network(int&); + void check_suspend_network(double, int&); int suspend_network(int reason); int resume_network(); void install_global_prefs(); diff --git a/client/cs_prefs.C b/client/cs_prefs.C index c48b838958..ba76566306 100644 --- a/client/cs_prefs.C +++ b/client/cs_prefs.C @@ -131,9 +131,13 @@ inline bool now_between_two_hours(int start_hour, int end_hour) { // See if (on the basis of user run request and prefs) // we should suspend activities. // -void CLIENT_STATE::check_suspend_activities(int& reason) { +void CLIENT_STATE::check_suspend_activities(double now, int& reason) { + static double last_time = 0; reason = 0; + if (now - last_time < 5.0) return; + last_time = now; + // Don't work while we're running CPU benchmarks // if (are_cpu_benchmarks_running()) { @@ -204,9 +208,13 @@ int CLIENT_STATE::resume_activities() { return 0; } -void CLIENT_STATE::check_suspend_network(int& reason) { +void CLIENT_STATE::check_suspend_network(double now, int& reason) { + static double last_time=0; reason = 0; + if (now - last_time < 5.0) return; + last_time = now; + if (user_network_request == USER_RUN_REQUEST_ALWAYS) return; if (user_network_request == USER_RUN_REQUEST_NEVER) { reason |= SUSPEND_REASON_USER_REQ; diff --git a/client/main.C b/client/main.C index 2e34bff22f..659274b121 100644 --- a/client/main.C +++ b/client/main.C @@ -279,7 +279,7 @@ int boinc_main_loop(int argc, char** argv) { dt = dtime(); if (!gstate.do_something(dt)) { dt = dtime(); - gstate.net_sleep(1.); + gstate.net_sleep(0.1); dt = dtime() - dt; log_messages.printf(CLIENT_MSG_LOG::DEBUG_TIME, "SLEPT %f SECONDS\n", dt); fflush(stdout);