add proc_state.processor

This commit is contained in:
Doug MacEachern 2005-11-23 01:16:52 +00:00
parent 2f1ecff921
commit 6b7a36f521
6 changed files with 20 additions and 1 deletions

View File

@ -353,6 +353,11 @@ my %classes = (
desc => 'Number of active threads', desc => 'Number of active threads',
plat => 'AHLSW' plat => 'AHLSW'
}, },
{
name => 'processor', type => 'Int',
desc => 'Processor number last run on',
plat => ''
},
], ],
ProcFd => [ ProcFd => [
{ {

View File

@ -22,6 +22,7 @@ public class TestProcState extends SigarTestCase {
char state = procState.getState(); char state = procState.getState();
traceln(procState.getName() + "=" + state); traceln(procState.getName() + "=" + state);
traceln("threads=" + procState.getThreads()); traceln("threads=" + procState.getThreads());
traceln("processor=" + procState.getProcessor());
traceln("priority=" + procState.getPriority()); traceln("priority=" + procState.getPriority());
assertTrue((state == 'R') || (state == 'S')); assertTrue((state == 'R') || (state == 'S'));

View File

@ -255,6 +255,7 @@ typedef struct {
int tty; int tty;
int priority; int priority;
int nice; int nice;
int processor;
sigar_uint64_t threads; sigar_uint64_t threads;
} sigar_proc_state_t; } sigar_proc_state_t;

View File

@ -1142,16 +1142,26 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
{ {
int status = sigar_getprocs(sigar, pid); int status = sigar_getprocs(sigar, pid);
struct procsinfo *pinfo = sigar->pinfo; struct procsinfo *pinfo = sigar->pinfo;
tid_t tid = 0;
struct thrdsinfo64 thrinfo;
if (status != SIGAR_OK) { if (status != SIGAR_OK) {
return status; 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); SIGAR_SSTRCPY(procstate->name, pinfo->pi_comm);
procstate->ppid = pinfo->pi_ppid; procstate->ppid = pinfo->pi_ppid;
procstate->nice = pinfo->pi_nice; procstate->nice = pinfo->pi_nice;
procstate->tty = pinfo->pi_ttyd; procstate->tty = pinfo->pi_ttyd;
procstate->priority = SIGAR_FIELD_NOTIMPL; /* XXX getthrds() */
procstate->threads = pinfo->pi_thcount; procstate->threads = pinfo->pi_thcount;
switch (pinfo->pi_state) { switch (pinfo->pi_state) {

View File

@ -333,6 +333,7 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
procstate->priority = pinfo->pst_pri; procstate->priority = pinfo->pst_pri;
procstate->nice = pinfo->pst_nice; procstate->nice = pinfo->pst_nice;
procstate->threads = pinfo->pst_nlwps; procstate->threads = pinfo->pst_nlwps;
procstate->processor = pinfo->pst_procnum;
switch (pinfo->pst_stat) { switch (pinfo->pst_stat) {
case PS_SLEEP: case PS_SLEEP:

View File

@ -661,6 +661,7 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
procstate->priority = pinfo->pr_lwp.pr_pri; procstate->priority = pinfo->pr_lwp.pr_pri;
procstate->nice = pinfo->pr_lwp.pr_nice - NZERO; procstate->nice = pinfo->pr_lwp.pr_nice - NZERO;
procstate->threads = pinfo->pr_nlwp; procstate->threads = pinfo->pr_nlwp;
procstate->processor = pinfo->pr_lwp.pr_onpro;
switch (pinfo->pr_lwp.pr_state) { switch (pinfo->pr_lwp.pr_state) {
case SONPROC: case SONPROC: