*** empty log message ***

svn path=/trunk/boinc/; revision=12257
This commit is contained in:
David Anderson 2007-03-20 23:12:22 +00:00
parent aacfe0c952
commit 52793262e1
5 changed files with 85 additions and 50 deletions

View File

@ -925,7 +925,9 @@ int boinc_checkpoint_completed() {
boinc_worker_thread_cpu_time(cur_cpu);
last_wu_cpu_time = cur_cpu + aid.wu_cpu_time;
last_checkpoint_cpu_time = last_wu_cpu_time;
update_app_progress(last_checkpoint_cpu_time, last_checkpoint_cpu_time);
if (options.send_status_msgs) {
update_app_progress(last_checkpoint_cpu_time, last_checkpoint_cpu_time);
}
time_until_checkpoint = (int)aid.checkpoint_period;
in_critical_section = false;
ready_to_checkpoint = false;

View File

@ -2722,3 +2722,15 @@ David 20 Mar 2007
cs_benchmark.C
lib/
util.C,h
David 20 Mar 2007
- API: boinc_checkpoint_completed(): don't call update_app_progress()
unless options.send_status_msgs is set
(fixes bug in wrappers that call this)
- lib: add linux_cpu_time() function (get CPU time of another process)
api/
boinc_api.C
lib/
procinfo_unix.C
util.C,h

View File

@ -96,53 +96,54 @@ struct PROC_STAT {
};
int PROC_STAT::parse(char* buf) {
int n = sscanf(buf, "%d %s %c %d %d %d %d %d "
"%lu %lu %lu %lu %lu %lu %lu "
"%d %d %d %d %d %d "
"%lu %lu "
"%d "
"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%d %d",
&pid,
comm,
&state,
&ppid,
&pgrp,
&session,
&tty_nr,
&tpgid,
&flags,
&minflt,
&cminflt,
&majflt,
&cmajflt,
&utime,
&stime,
&cutime,
&cstime,
&priority,
&nice,
&zero,
&itrealvalue,
&starttime,
&vsize,
&rss,
&rlim,
&startcode,
&endcode,
&startstack,
&kstkesp,
&kstkeip,
&signal,
&blocked,
&sigignore,
&sigcatch,
&wchan,
&nswap,
&cnswap,
&exit_signal,
&processor
);
int n = sscanf(buf,
"%d %s %c %d %d %d %d %d "
"%lu %lu %lu %lu %lu %lu %lu "
"%d %d %d %d %d %d "
"%lu %lu "
"%d "
"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%d %d",
&pid,
comm,
&state,
&ppid,
&pgrp,
&session,
&tty_nr,
&tpgid,
&flags,
&minflt,
&cminflt,
&majflt,
&cmajflt,
&utime,
&stime,
&cutime,
&cstime,
&priority,
&nice,
&zero,
&itrealvalue,
&starttime,
&vsize,
&rss,
&rlim,
&startcode,
&endcode,
&startstack,
&kstkesp,
&kstkeip,
&signal,
&blocked,
&sigignore,
&sigcatch,
&wchan,
&nswap,
&cnswap,
&exit_signal,
&processor
);
if (n == 39) return 0;
// I don't see a good choice of ERR_ for this...
@ -189,9 +190,9 @@ int procinfo_setup(vector<PROCINFO>& pi) {
if (fd) {
if (fread(&prusage, sizeof(prusage_t), 1, fd) == 1) {
p.user_time = (float)prusage.pr_utime.tv_sec +
((float)prusage.pr_utime.tv_nsec)/1e+9;
((float)prusage.pr_utime.tv_nsec)/1e+9;
p.kernel_time = (float)prusage.pr_stime.tv_sec +
((float)prusage.pr_utime.tv_nsec)/1e+9;
((float)prusage.pr_utime.tv_nsec)/1e+9;
// page faults: I/O + non I/O
p.page_fault_count = prusage.pr_majf + prusage.pr_minf;
}

View File

@ -489,4 +489,23 @@ int wait_client_mutex(const char* dir, double timeout) {
return ERR_ALREADY_RUNNING;
}
#ifndef _WIN32
// (linux) return current CPU time of the given process
//
double linux_cpu_time(int pid) {
FILE *file;
char file_name[24];
unsigned long utime = 0, stime = 0;
int n;
sprintf(file_name,"/proc/%d/stat",pid);
if ((file = fopen(file_name,"r")) != NULL) {
n = fscanf(file,"%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%lu%lu",&utime,&stime);
fclose(file);
if (n != 2) return 0;
}
return (double)(utime + stime)/100;
}
#endif
const char *BOINC_RCSID_ab65c90e1e = "$Id$";

View File

@ -71,6 +71,7 @@ extern int check_security(int use_sandbox, int isManager);
// setpriority(2) arg to run in background
// (don't use 20 because
static const int PROCESS_IDLE_PRIORITY = 19;
extern double linux_cpu_time(int pid);
#endif
extern void update_average(double, double, double, double&, double&);