- client, Unix: always use 1 (rather than slot#) in ftok().

Slot is already encoded in path.
- client, Linux: get memory size from /proc/meminfo
    rather than sysconf()
    
client/
    app_start.C
    hostinfo_unix.C

svn path=/trunk/boinc/; revision=12731
This commit is contained in:
David Anderson 2007-05-23 20:36:49 +00:00
parent 076505fd1c
commit 9f07182cf6
3 changed files with 32 additions and 2 deletions

View File

@ -5255,3 +5255,13 @@ David 23 May 2007
client/
hostinfo_unix.C
David 23 May 2007
- client, Unix: always use 1 (rather than slot#) in ftok().
Slot is already encoded in path.
- client, Linux: get memory size from /proc/meminfo
rather than sysconf()
client/
app_start.C
hostinfo_unix.C

View File

@ -147,7 +147,7 @@ int ACTIVE_TASK::get_shmem_seg_name() {
//
FILE* f = boinc_fopen(init_data_path, "w");
if (f) fclose(f);
shmem_seg_name = ftok(init_data_path, slot);
shmem_seg_name = ftok(init_data_path, 1);
if (shmem_seg_name == -1) return ERR_SHMEM_NAME;
#endif
return 0;

View File

@ -243,6 +243,25 @@ bool HOST_INFO::host_is_running_on_batteries() {
}
#ifdef linux
static void parse_meminfo_linux(HOST_INFO& host) {
char buf[256];
double x;
FILE* f = fopen("/proc/meminfo", "r");
if (!f) return;
while (fgets(buf, 256, f)) {
if (strstr(buf, "MemTotal:")) {
sscanf(buf, "MemTotal: %lf", &x);
host.m_nbytes = x*1024;
} else if (strstr(buf, "SwapTotal:")) {
sscanf(buf, "SwapTotal: %lf", &x);
host.m_swap = x*1024;
} else if (strstr(buf, "Mem:")) {
sscanf(buf, "Mem: %lf", &host.m_nbytes);
} else if (strstr(buf, "Swap:")) {
sscanf(buf, "Swap: %lf", &host.m_swap);
}
}
}
// Unfortunately the format of /proc/cpuinfo is not standardized.
// See http://people.nl.linux.org/~hch/cpuinfo/ for some examples.
@ -574,12 +593,13 @@ int HOST_INFO::get_host_info() {
DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulMem, sizeof(ulMem));
m_swap = ulMem;
}
#elif defined(linux)
parse_meminfo_linux(*this);
#elif defined(_SC_USEABLE_MEMORY)
// UnixWare
m_nbytes = (double)sysconf(_SC_PAGESIZE)
* (double)sysconf(_SC_USEABLE_MEMORY);
#elif defined(_SC_PHYS_PAGES)
// Linux
m_nbytes = (double)sysconf(_SC_PAGESIZE) * (double)sysconf(_SC_PHYS_PAGES);
if (m_nbytes < 0) {
msg_printf(NULL, MSG_INTERNAL_ERROR,