mirror of https://github.com/BOINC/boinc.git
client: Add code for determining non-BOINC CPU time for GR and PtP clients (Mac & Windows)
svn path=/trunk/boinc/; revision=21169
This commit is contained in:
parent
2e41153d8b
commit
ab7df01162
|
@ -2741,3 +2741,11 @@ David 10 Apr 2010
|
|||
sched/
|
||||
sched_version.cpp
|
||||
sched_send.cpp
|
||||
|
||||
Charlie 13 Apr 2010
|
||||
- client: Add code for determining non-BOINC CPU time for GridRepublic
|
||||
and Progress Thru Processors clients (Mac & Windows).
|
||||
|
||||
lib/
|
||||
procinfo_mac.cpp
|
||||
procinfo_win.cpp
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
|
||||
using std::vector;
|
||||
|
||||
// Possible values of iBrandId:
|
||||
#define BOINC_BRAND_ID 0
|
||||
#define GRIDREPUBLIC_BRAND_ID 1
|
||||
#define PROGRESSTHRUPROCESSORS_BRAND_ID 2
|
||||
|
||||
|
||||
// build table of all processes in system
|
||||
//
|
||||
|
@ -43,6 +48,19 @@ int procinfo_setup(vector<PROCINFO>& pi) {
|
|||
PROCINFO p;
|
||||
int c, real_mem, virtual_mem, hours;
|
||||
char* lf;
|
||||
static long iBrandID = -1;
|
||||
|
||||
if (iBrandID < 0) {
|
||||
iBrandID = BOINC_BRAND_ID;
|
||||
|
||||
// For GridRepublic or ProgressThruProcessors, the Mac
|
||||
// installer put a branding file in our data directory
|
||||
FILE *f = fopen("/Library/Application Support/BOINC Data/Branding", "r");
|
||||
if (f) {
|
||||
fscanf(f, "BrandId=%ld\n", &iBrandID);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
#if SHOW_TIMING
|
||||
UnsignedWide start, end, elapsed;
|
||||
|
@ -107,6 +125,19 @@ int procinfo_setup(vector<PROCINFO>& pi) {
|
|||
p.swap_size = (double)virtual_mem * 1024.;
|
||||
p.user_time += 60. * (float)hours;
|
||||
p.is_boinc_app = (p.id == pid || strcasestr(p.command, "boinc"));
|
||||
|
||||
switch (iBrandID) {
|
||||
case GRIDREPUBLIC_BRAND_ID:
|
||||
if (strcasestr(p.command, "GridRepublic")) {
|
||||
p.is_boinc_app = true;
|
||||
}
|
||||
break;
|
||||
case PROGRESSTHRUPROCESSORS_BRAND_ID:
|
||||
if (strcasestr(p.command, "Progress Thru Processors")) {
|
||||
p.is_boinc_app = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
pi.push_back(p);
|
||||
}
|
||||
|
||||
|
@ -145,7 +176,7 @@ void add_proc_totals(PROCINFO& pi, vector<PROCINFO>& piv, int pid, char* graphic
|
|||
}
|
||||
// look for child process of this one
|
||||
if (p.parentid == pid) {
|
||||
add_proc_totals(pi, piv, p.id, graphics_exec_file, i+1); // recursion - woo hoo!
|
||||
add_proc_totals(pi, piv, p.id, graphics_exec_file, i+1, rlvl+1); // recursion - woo hoo!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
|
||||
using std::vector;
|
||||
|
||||
// Possible values of iBrandId:
|
||||
#define BOINC_BRAND_ID 0
|
||||
#define GRIDREPUBLIC_BRAND_ID 1
|
||||
#define PROGRESSTHRUPROCESSORS_BRAND_ID 2
|
||||
|
||||
// NtQuerySystemInformation
|
||||
typedef NTSTATUS (WINAPI *tNTQSI)(
|
||||
ULONG SystemInformationClass,
|
||||
|
@ -69,10 +74,22 @@ int get_procinfo_XP(vector<PROCINFO>& pi) {
|
|||
PVOID pBuffer = NULL;
|
||||
PSYSTEM_PROCESSES pProcesses = NULL;
|
||||
static DWORD pid = 0;
|
||||
static long iBrandID = -1;
|
||||
|
||||
if (!pid) {
|
||||
pid = GetCurrentProcessId();
|
||||
}
|
||||
|
||||
if (iBrandID < 0) {
|
||||
iBrandID = BOINC_BRAND_ID;
|
||||
if (boinc_file_exists("gridrepublic.exe")) {
|
||||
iBrandID = GRIDREPUBLIC_BRAND_ID;
|
||||
} else
|
||||
if (boinc_file_exists("progressthruprocessors.exe")) {
|
||||
iBrandID = PROGRESSTHRUPROCESSORS_BRAND_ID;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("FILETIME: %d\n", sizeof(FILETIME));
|
||||
printf("LARGE_INTEGER: %d\n", sizeof(LARGE_INTEGER));
|
||||
|
@ -104,6 +121,20 @@ int get_procinfo_XP(vector<PROCINFO>& pi) {
|
|||
NULL, NULL
|
||||
);
|
||||
p.is_boinc_app = (p.id == pid) || (strcasestr(p.command, "boinc") != NULL);
|
||||
|
||||
switch (iBrandID) {
|
||||
case GRIDREPUBLIC_BRAND_ID:
|
||||
if (strcasestr(p.command, "gridrepublic") != NULL) {
|
||||
p.is_boinc_app = true;
|
||||
}
|
||||
break;
|
||||
case PROGRESSTHRUPROCESSORS_BRAND_ID:
|
||||
if (strcasestr(p.command, "progressthruprocessors") != NULL) {
|
||||
p.is_boinc_app = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pi.push_back(p);
|
||||
if (!pProcesses->NextEntryDelta) {
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue