*** empty log message ***

svn path=/trunk/boinc/; revision=5732
This commit is contained in:
David Anderson 2005-03-29 23:13:28 +00:00
parent 0567b9caa2
commit dc0bf925b8
4 changed files with 98 additions and 85 deletions

View File

@ -100,11 +100,82 @@ HANDLE worker_thread_handle;
static MMRESULT timer_id;
#endif
static int setup_shared_mem();
static int update_app_progress(double cpu_t, double cp_cpu_t, double ws_t);
static BOINC_OPTIONS options;
static volatile BOINC_STATUS boinc_status;
static int setup_shared_mem() {
if (standalone) {
fprintf(stderr, "Standalone mode, so not using shared memory.\n");
return 0;
}
app_client_shm = new APP_CLIENT_SHM;
#ifdef _WIN32
char buf[256];
sprintf(buf, "%s%s", SHM_PREFIX, aid.shmem_seg_name);
hSharedMem = attach_shmem(buf, (void**)&app_client_shm->shm);
if (hSharedMem == NULL) {
delete app_client_shm;
app_client_shm = NULL;
}
#else
if (attach_shmem(aid.shmem_seg_name, (void**)&app_client_shm->shm)) {
delete app_client_shm;
app_client_shm = NULL;
}
#endif
if (app_client_shm == NULL) return -1;
return 0;
}
static int boinc_worker_thread_cpu_time(double& cpu) {
#ifdef _WIN32
if (boinc_thread_cpu_time(worker_thread_handle, cpu)) {
cpu = nrunning_ticks * TIMER_PERIOD; // for Win9x
}
return 0;
#else
// no CPU time calls in pthreads - return process total
//
return boinc_calling_thread_cpu_time(cpu);
#endif
}
// communicate to the core client (via shared mem)
// the current CPU time and fraction done
//
static int update_app_progress(
double cpu_t, double cp_cpu_t, double /*ws_t*/
) {
char msg_buf[MSG_CHANNEL_SIZE], buf[256];
double vm, rs;
if (!app_client_shm) return 0;
sprintf(msg_buf,
"<current_cpu_time>%10.4f</current_cpu_time>\n"
"<checkpoint_cpu_time>%.15e</checkpoint_cpu_time>\n",
cpu_t, cp_cpu_t
);
if (fraction_done >= 0) {
double range = aid.fraction_done_end - aid.fraction_done_start;
double fdone = aid.fraction_done_start + fraction_done*range;
sprintf(buf, "<fraction_done>%2.8f</fraction_done>\n", fdone);
strcat(msg_buf, buf);
}
if (!mem_usage(vm, rs)) {
sprintf(buf,
"<vm_bytes>%f</vm_bytes>\n"
"<rss_bytes>%flu</rss_bytes>\n",
vm, rs
);
strcat(msg_buf, buf);
}
app_client_shm->shm->app_status.send_msg(msg_buf);
return 0;
}
// the following 2 functions are used when there's no graphics
//
int boinc_init() {
@ -197,8 +268,8 @@ static void send_trickle_up_msg() {
//
int boinc_finish(int status) {
if (options.send_status_msgs) {
boinc_calling_thread_cpu_time(last_checkpoint_cpu_time);
last_checkpoint_cpu_time += aid.wu_cpu_time;
boinc_worker_thread_cpu_time(last_checkpoint_cpu_time);
last_checkpoint_cpu_time += initial_wu_cpu_time;
update_app_progress(last_checkpoint_cpu_time, last_checkpoint_cpu_time, 0);
}
if (options.handle_trickle_ups) {
@ -308,40 +379,6 @@ int boinc_report_app_status(
return 0;
}
// communicate to the core client (via shared mem)
// the current CPU time and fraction done
//
static int update_app_progress(
double cpu_t, double cp_cpu_t, double /*ws_t*/
) {
char msg_buf[MSG_CHANNEL_SIZE], buf[256];
double vm, rs;
if (!app_client_shm) return 0;
sprintf(msg_buf,
"<current_cpu_time>%10.4f</current_cpu_time>\n"
"<checkpoint_cpu_time>%.15e</checkpoint_cpu_time>\n",
cpu_t, cp_cpu_t
);
if (fraction_done >= 0) {
double range = aid.fraction_done_end - aid.fraction_done_start;
double fdone = aid.fraction_done_start + fraction_done*range;
sprintf(buf, "<fraction_done>%2.8f</fraction_done>\n", fdone);
strcat(msg_buf, buf);
}
if (!mem_usage(vm, rs)) {
sprintf(buf,
"<vm_bytes>%f</vm_bytes>\n"
"<rss_bytes>%flu</rss_bytes>\n",
vm, rs
);
strcat(msg_buf, buf);
}
app_client_shm->shm->app_status.send_msg(msg_buf);
return 0;
}
int boinc_get_init_data(APP_INIT_DATA& app_init_data) {
app_init_data = aid;
return 0;
@ -355,23 +392,6 @@ int boinc_wu_cpu_time(double& cpu_t) {
return 0;
}
#ifdef _WIN32
int boinc_worker_thread_cpu_time(double& cpu) {
if (boinc_thread_cpu_time(worker_thread_handle, cpu)) {
cpu = nrunning_ticks * TIMER_PERIOD; // for Win9x
}
return 0;
}
#else
int boinc_worker_thread_cpu_time(double& cpu) {
return boinc_calling_thread_cpu_time(cpu);
}
#endif // _WIN32
static void handle_heartbeat_msg() {
char buf[MSG_CHANNEL_SIZE];
if (app_client_shm->shm->heartbeat.get_msg(buf)) {
@ -559,31 +579,6 @@ int set_worker_timer() {
return retval;
}
static int setup_shared_mem() {
if (standalone) {
fprintf(stderr, "Standalone mode, so not using shared memory.\n");
return 0;
}
app_client_shm = new APP_CLIENT_SHM;
#ifdef _WIN32
char buf[256];
sprintf(buf, "%s%s", SHM_PREFIX, aid.shmem_seg_name);
hSharedMem = attach_shmem(buf, (void**)&app_client_shm->shm);
if (hSharedMem == NULL) {
delete app_client_shm;
app_client_shm = NULL;
}
#else
if (attach_shmem(aid.shmem_seg_name, (void**)&app_client_shm->shm)) {
delete app_client_shm;
app_client_shm = NULL;
}
#endif
if (app_client_shm == NULL) return -1;
return 0;
}
int boinc_send_trickle_up(char* variety, char* p) {
if (!options.handle_trickle_ups) return ERR_NO_OPTION;
FILE* f = boinc_fopen(TRICKLE_UP_FILENAME, "wb");

View File

@ -25557,7 +25557,7 @@ Rom 5 Mar 2005
client_state.C
David 5 Mar 2005
- initial support for GUI RPC protection
- initial support for GUI RPC authentication
If the core client finds a file called "gui_rpc_auth.cfg",
it reads a password from it, and all GUI RPC requests
must authenticate using a challenge/response sequence,
@ -26260,3 +26260,18 @@ David 29 Mar 2005
lib/
shmem.C
David 29 Mar 2005
- API: in boinc_finish(),
call boinc_worker_thread_cpu_time() instead of
boinc_calling_thread_cpu_time()
(since the graphics thread can call boinc_finish()).
Also, offset CPU time by initial_wu_cpu_time
instead of aid.wu_cpu_time
This may help "zero CPU time" problems, but I doubt it
api/
boinc_api.C
lib/
util.C

View File

@ -24,14 +24,14 @@ function page_head($title) {
<nobr><font size='2'>Last modified $d</font></nobr>
</td>
</tr></table>
<hr size=0 noshade>
<hr size=1>
";
}
function page_tail() {
$y = date("Y ");
echo "
<hr size='0' noshade/>
<hr size=1>
<p align='center'>
<a href='/'>Return to BOINC main page</a>
<br/><br/>

View File

@ -728,15 +728,18 @@ int boinc_calling_thread_cpu_time(double& cpu) {
#else
// Unix: pthreads doesn't seem to provide an API for getting
// per-thread CPU time. So just get the process's CPU time
//
int boinc_calling_thread_cpu_time(double &cpu_t) {
int retval;
struct rusage ru;
retval = getrusage(RUSAGE_SELF, &ru);
if (retval) {
fprintf(stderr, "error: could not get CPU time\n");
return ERR_GETRUSAGE;
}
// Sum the user and system time spent in this process
// Sum the user and system time
//
cpu_t = (double)ru.ru_utime.tv_sec + (((double)ru.ru_utime.tv_usec) / ((double)1000000.0));
cpu_t += (double)ru.ru_stime.tv_sec + (((double)ru.ru_stime.tv_usec) / ((double)1000000.0));
return 0;