From 610d4cfa77cfb35a54f3ec259e6f61699ecaa78e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 3 Jun 2007 19:37:45 +0000 Subject: [PATCH] - client: allow suspension of non-CPU-intensive project or app (undoes checkin of 25 Jan 2005; I don't remember why we made that change. Next time put in checkin notes!) - client: Linux: show error msg if can't open /proc/cpuinfo or /proc/meminfo; set memory size of 1 GB in latter case. Remove duplicate code that read /proc/meminfo - 'start' script; handle 0 in tasks and daemon elements of config.xml (can't handle , however). client/ gui_rpc_server_ops.C hostinfo_unix.C sched/ feeder.C start svn path=/trunk/boinc/; revision=12807 --- checkin_notes | 17 ++++++++++++++++ client/gui_rpc_server_ops.C | 20 ++++++------------- client/hostinfo_unix.C | 39 +++++++++++++++++-------------------- doc/projects.inc | 2 +- sched/feeder.C | 9 +++++---- sched/start | 4 ++-- 6 files changed, 49 insertions(+), 42 deletions(-) diff --git a/checkin_notes b/checkin_notes index ebb21ebf1c..61d5e74145 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5689,3 +5689,20 @@ David 1 June 2007 client/ client_state.C net_stats.C + +David 3 June 2007 + - client: allow suspension of non-CPU-intensive project or app + (undoes checkin of 25 Jan 2005; I don't remember why we + made that change. Next time put in checkin notes!) + - client: Linux: show error msg if can't open /proc/cpuinfo + or /proc/meminfo; set memory size of 1 GB in latter case. + Remove duplicate code that read /proc/meminfo + - 'start' script; handle 0 in tasks and daemon + elements of config.xml (can't handle , however). + + client/ + gui_rpc_server_ops.C + hostinfo_unix.C + sched/ + feeder.C + start diff --git a/client/gui_rpc_server_ops.C b/client/gui_rpc_server_ops.C index 8bd92b93fa..00dd52f6cf 100644 --- a/client/gui_rpc_server_ops.C +++ b/client/gui_rpc_server_ops.C @@ -236,14 +236,10 @@ static void handle_project_op(char* buf, MIOFILE& fout, const char* op) { gstate.request_work_fetch("project reset by user"); gstate.reset_project(p); // writes state file } else if (!strcmp(op, "suspend")) { - if (p->non_cpu_intensive) { - msg_printf(p, MSG_USER_ERROR, "Can't suspend non-CPU-intensive project"); - } else { - p->suspended_via_gui = true; - gstate.request_schedule_cpus("project suspended by user"); - gstate.request_work_fetch("project suspended by user"); - gstate.set_client_state_dirty("Project suspended by user"); - } + p->suspended_via_gui = true; + gstate.request_schedule_cpus("project suspended by user"); + gstate.request_work_fetch("project suspended by user"); + gstate.set_client_state_dirty("Project suspended by user"); } else if (!strcmp(op, "resume")) { p->suspended_via_gui = false; gstate.request_schedule_cpus("project resumed by user"); @@ -478,12 +474,8 @@ static void handle_result_op(char* buf, MIOFILE& fout, const char* op) { } gstate.request_work_fetch("result aborted by user"); } else if (!strcmp(op, "suspend")) { - if (p->non_cpu_intensive) { - msg_printf(p, MSG_USER_ERROR, "Can't suspend non-CPU-intensive result"); - } else { - rp->suspended_via_gui = true; - gstate.request_work_fetch("result suspended by user"); - } + rp->suspended_via_gui = true; + gstate.request_work_fetch("result suspended by user"); } else if (!strcmp(op, "resume")) { rp->suspended_via_gui = false; } diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index 3e8204c00e..b003c1e3af 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -247,7 +247,14 @@ static void parse_meminfo_linux(HOST_INFO& host) { char buf[256]; double x; FILE* f = fopen("/proc/meminfo", "r"); - if (!f) return; + if (!f) { + msg_printf(NULL, MSG_USER_ERROR, + "Can't open /proc/meminfo - defaulting to 1 GB." + ); + host.m_nbytes = GIGA; + host.m_swap = GIGA; + return; + } while (fgets(buf, 256, f)) { if (strstr(buf, "MemTotal:")) { sscanf(buf, "MemTotal: %lf", &x); @@ -261,6 +268,7 @@ static void parse_meminfo_linux(HOST_INFO& host) { sscanf(buf, "Swap: %lf", &host.m_swap); } } + fclose(f); } // Unfortunately the format of /proc/cpuinfo is not standardized. @@ -277,7 +285,12 @@ static void parse_cpuinfo_linux(HOST_INFO& host) { char buf2[256]; FILE* f = fopen("/proc/cpuinfo", "r"); - if (!f) return; + if (!f) { + msg_printf(NULL, MSG_USER_ERROR, "Can't open /proc/cpuinfo."); + strcpy(host.p_model, "unknown"); + strcpy(host.p_vendor, "unknown"); + return; + } #ifdef __mips__ strcpy(host.p_model, "MIPS "); @@ -600,8 +613,7 @@ int HOST_INFO::get_host_info() { parse_meminfo_linux(*this); #elif defined(_SC_USEABLE_MEMORY) // UnixWare - m_nbytes = (double)sysconf(_SC_PAGESIZE) - * (double)sysconf(_SC_USEABLE_MEMORY); + m_nbytes = (double)sysconf(_SC_PAGESIZE) * (double)sysconf(_SC_USEABLE_MEMORY); #elif defined(_SC_PHYS_PAGES) m_nbytes = (double)sysconf(_SC_PAGESIZE) * (double)sysconf(_SC_PHYS_PAGES); if (m_nbytes < 0) { @@ -661,24 +673,9 @@ int HOST_INFO::get_host_info() { swapctl(SWAP_STATS, s, n); m_swap = 0.0; for (i = 0; i < n; i ++) { - if (s[i].se_flags & SWF_ENABLE) - m_swap += 512. * (double)s[i].se_nblks; - } -#elif defined(HAVE__PROC_MEMINFO) - // Linux - FILE *fp; - if ((fp = fopen("/proc/meminfo", "r")) != 0) { - char minfo_buf[1024]; - int n; - if ((n = fread(minfo_buf, sizeof(char), sizeof(minfo_buf)-1, fp))) { - char *p; - minfo_buf[n] = '\0'; - if ((p = strstr(minfo_buf, "SwapTotal:"))) { - p += 10; // move past "SwapTotal:" - m_swap = 1024.*(double) strtoul(p, NULL, 10); - } + if (s[i].se_flags & SWF_ENABLE) { + m_swap += 512. * (double)s[i].se_nblks; } - fclose(fp); } #elif defined(__APPLE__) // The sysctl(vm.vmmeter) function doesn't work on OS X. However, swap diff --git a/doc/projects.inc b/doc/projects.inc index 1476b899be..cc1ba36d52 100644 --- a/doc/projects.inc +++ b/doc/projects.inc @@ -103,7 +103,7 @@ $astro_phys_chem = array( ), array( "LHC@home", - "http://lhcathome.cern.ch/", + "http://lhcathome.cern.ch/lhcathome/", "CERN (European Organization for Nuclear Research)", "Physics", "The Large Hadron Collider (LHC) is a particle accelerator which is being built at CERN, the European Organization for Nuclear Research, the world's largest particle physics laboratory. When it switches on in 2007, it will be the most powerful instrument ever built to investigate on particles proprieties. LHC@home simulates particles traveling around the LHC to study the stability of their orbits.", diff --git a/sched/feeder.C b/sched/feeder.C index 299331525e..eba84d0f4a 100644 --- a/sched/feeder.C +++ b/sched/feeder.C @@ -132,12 +132,12 @@ int check_reread_trigger() { return 0; } -// Scan work items for a given appp until one found -// that is not already on the shared memory segment. +// Scan work items for a given app until one found +// that is not already in the shared memory segment. // Errors that can occur: // 1) No valid work item found even after restarting the enumeration // ACTION: return false -// 2) The work item can be for a app that doesn't exist in the database +// 2) The work item is for a app that doesn't exist in the database // ACTION: exit application // static bool find_work_item( @@ -169,7 +169,8 @@ static bool find_work_item( restarted_enum = true; log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL, "restarted enumeration for appid %d\n", - ssp->apps[work_item_index].id); + ssp->apps[work_item_index].id + ); } else { // Check for a work item with an invalid application id // diff --git a/sched/start b/sched/start index 7bc0e2f6e7..af3f18b463 100755 --- a/sched/start +++ b/sched/start @@ -117,7 +117,7 @@ def assign_task_defaults(): if not host: task.host = config.config.host disabled = task.__dict__.get('disabled') - if disabled: + if disabled and disabled != "0": task.disabled = 1 else: task.disabled = 0 @@ -126,7 +126,7 @@ def assign_task_defaults(): if not host: task.host = config.config.host disabled = task.__dict__.get('disabled') - if disabled: + if disabled and disabled != "0": task.disabled = 1 else: task.disabled = 0