add proc_state.processor
This commit is contained in:
		
							parent
							
								
									2f1ecff921
								
							
						
					
					
						commit
						6b7a36f521
					
				@ -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 => [
 | 
			
		||||
      {
 | 
			
		||||
 | 
			
		||||
@ -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'));
 | 
			
		||||
 | 
			
		||||
@ -255,6 +255,7 @@ typedef struct {
 | 
			
		||||
    int tty;
 | 
			
		||||
    int priority;
 | 
			
		||||
    int nice;
 | 
			
		||||
    int processor;
 | 
			
		||||
    sigar_uint64_t threads;
 | 
			
		||||
} sigar_proc_state_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -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:
 | 
			
		||||
 | 
			
		||||
@ -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:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user