From 6b7a36f521047a6a98a5b38e52e3941d78556cfd Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 23 Nov 2005 01:16:52 +0000 Subject: [PATCH] add proc_state.processor --- bindings/java/src/jni/generate.pl | 5 +++++ .../src/net/hyperic/sigar/test/TestProcState.java | 1 + include/sigar.h | 1 + src/os/aix/aix_sigar.c | 12 +++++++++++- src/os/hpux/hpux_sigar.c | 1 + src/os/solaris/solaris_sigar.c | 1 + 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 42986ef9..7b21cd32 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -353,6 +353,11 @@ my %classes = ( desc => 'Number of active threads', plat => 'AHLSW' }, + { + name => 'processor', type => 'Int', + desc => 'Processor number last run on', + plat => '' + }, ], ProcFd => [ { diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcState.java b/bindings/java/src/net/hyperic/sigar/test/TestProcState.java index 90abaa1e..23431995 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcState.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcState.java @@ -22,6 +22,7 @@ public class TestProcState extends SigarTestCase { char state = procState.getState(); traceln(procState.getName() + "=" + state); traceln("threads=" + procState.getThreads()); + traceln("processor=" + procState.getProcessor()); traceln("priority=" + procState.getPriority()); assertTrue((state == 'R') || (state == 'S')); diff --git a/include/sigar.h b/include/sigar.h index 129febca..08f8283f 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -255,6 +255,7 @@ typedef struct { int tty; int priority; int nice; + int processor; sigar_uint64_t threads; } sigar_proc_state_t; diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index 72a6f9d0..73108e66 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -1142,16 +1142,26 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, { int status = sigar_getprocs(sigar, pid); struct procsinfo *pinfo = sigar->pinfo; + tid_t tid = 0; + struct thrdsinfo64 thrinfo; if (status != SIGAR_OK) { return status; } + if (getthrds(pid, &thrinfo, sizeof(thrinfo), &tid, 1) == 1) { + procstate->priority = thrinfo.ti_pri; + procstate->processor = thrinfo.ti_affinity; + } + else { + procstate->priority = SIGAR_FIELD_NOTIMPL; + procstate->processor = SIGAR_FIELD_NOTIMPL; + } + SIGAR_SSTRCPY(procstate->name, pinfo->pi_comm); procstate->ppid = pinfo->pi_ppid; procstate->nice = pinfo->pi_nice; procstate->tty = pinfo->pi_ttyd; - procstate->priority = SIGAR_FIELD_NOTIMPL; /* XXX getthrds() */ procstate->threads = pinfo->pi_thcount; switch (pinfo->pi_state) { diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index 32908106..30eceb75 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -333,6 +333,7 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, procstate->priority = pinfo->pst_pri; procstate->nice = pinfo->pst_nice; procstate->threads = pinfo->pst_nlwps; + procstate->processor = pinfo->pst_procnum; switch (pinfo->pst_stat) { case PS_SLEEP: diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index a727a4cd..f345b49e 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -661,6 +661,7 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, procstate->priority = pinfo->pr_lwp.pr_pri; procstate->nice = pinfo->pr_lwp.pr_nice - NZERO; procstate->threads = pinfo->pr_nlwp; + procstate->processor = pinfo->pr_lwp.pr_onpro; switch (pinfo->pr_lwp.pr_state) { case SONPROC: