Hi Mladen,
I've got another one for that file. You optimized the original Solaris
contribution by changing division with a value to multiplication with
the reciprocal value. Unfortunately we are in integer land and the
divisor was bigger than 1, so now we always multiply by 0 :(
Patch attached an CC to mturk in case the attachment gets stripped.
Rainer
Index: jni/native/os/unix/system.c
===================================================================
--- jni/native/os/unix/system.c (revision 394052)
+++ jni/native/os/unix/system.c (working copy)
@@ -53,6 +53,7 @@
#if defined(sun)
#define MAX_PROC_PATH_LEN 64
#define MAX_CPUS 512
+#define CPU_TIME_RESOLUTION 1000
#define PSINFO_T_SZ sizeof(psinfo_t)
#define PRUSAGE_T_SZ sizeof(prusage_t)
@@ -148,8 +149,7 @@
int res = 0; /* general result state */
/* non-static variables - sysinfo/swapctl use */
long ret_sysconf; /* value returned from sysconf
call */
- long tck_dividend; /* factor used by transforming
tick numbers to milliseconds */
- long tck_divisor; /* divisor used by transforming
tick numbers to milliseconds */
+ long tck_divisor; /* divisor used for
transforming tick numbers to time units */
long sys_pagesize = sysconf(_SC_PAGESIZE); /* size of a system memory
page in bytes */
long sys_clk_tck = sysconf(_SC_CLK_TCK); /* number of system ticks per
second */
struct anoninfo info; /* structure for information
about sizes in anonymous memory system */
@@ -237,18 +237,7 @@
rv = apr_get_os_error();
}
else {
- tck_dividend = 1000;
- tck_divisor = sys_clk_tck;
- for (i = 0; i < 3; i++) {
- if (tck_divisor % 2 == 0) {
- tck_divisor = tck_divisor / 2;
- tck_dividend = tck_dividend / 2;
- }
- if (tck_divisor % 5 == 0) {
- tck_divisor = tck_divisor / 5;
- tck_dividend = tck_dividend / 5;
- }
- }
+ tck_divisor = sys_clk_tck / CPU_TIME_RESOLUTION;
if (kstat_ctl == NULL) {
kstat_ctl = kstat_open();
kid = kstat_ctl->kc_chain_id;
@@ -276,12 +265,11 @@
for (i = 0; i < cpu_count; i++) {
new_kid = kstat_read(kstat_ctl, kstat_cpu[i], NULL);
if (new_kid >= 0) {
- long tck_r = tck_dividend / tck_divisor;
cpu = ((cpu_stat_t *)kstat_cpu[i]->ks_data)->cpu_sysinfo;
- pvals[7] += (jlong)(((long)cpu.cpu[CPU_IDLE]) * tck_r);
- pvals[7] += (jlong)(((long)cpu.cpu[CPU_WAIT]) * tck_r);
- pvals[8] += (jlong)(((long)cpu.cpu[CPU_KERNEL]) * tck_r);
- pvals[9] += (jlong)(((long)cpu.cpu[CPU_USER]) * tck_r);
+ pvals[7] += (jlong)(((long)cpu.cpu[CPU_IDLE]) /
tck_divisor);
+ pvals[7] += (jlong)(((long)cpu.cpu[CPU_WAIT]) /
tck_divisor);
+ pvals[8] += (jlong)(((long)cpu.cpu[CPU_KERNEL]) /
tck_divisor);
+ pvals[9] += (jlong)(((long)cpu.cpu[CPU_USER]) /
tck_divisor);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]