321 |
u_quad_t u, st, ut, it, tot; |
u_quad_t u, st, ut, it, tot; |
322 |
#if (__FreeBSD_version < 300003) |
#if (__FreeBSD_version < 300003) |
323 |
long sec, usec; |
long sec, usec; |
324 |
#endif |
#endif |
325 |
|
|
326 |
st = p->p_sticks; |
st = p->p_sticks; |
327 |
ut = p->p_uticks; |
ut = p->p_uticks; |
440 |
int get_process_info_sysdep(ProcInfo_T p) { |
int get_process_info_sysdep(ProcInfo_T p) { |
441 |
|
|
442 |
struct kinfo_proc *pinfo; |
struct kinfo_proc *pinfo; |
443 |
struct user *u_addr = (struct user *)USRSTACK; |
|
444 |
|
/* Only needed for older versions of BSD that use kvm_uread */ |
445 |
|
/* struct user *u_addr = (struct user *)USRSTACK; */ |
446 |
struct pstats pstats; |
struct pstats pstats; |
447 |
struct plimit plimit; |
struct plimit plimit; |
448 |
struct vmspace *vms; |
struct vmspace *vms; |
469 |
/* ----------------------------- CPU TIMING ----------------------------*/ |
/* ----------------------------- CPU TIMING ----------------------------*/ |
470 |
/* Got it from libgtop/sysdep/freebsd/proctime.c */ |
/* Got it from libgtop/sysdep/freebsd/proctime.c */ |
471 |
|
|
472 |
if ((pinfo [0].kp_proc.p_flag & P_INMEM) && |
if (kvm_read (kvm_handle, |
473 |
|
(unsigned long) pinfo [0].kp_proc.p_stats, |
474 |
|
&pstats, sizeof (pstats)) == sizeof (pstats)) { |
475 |
|
|
476 |
|
/* Need to fix for different versions of BSD - I think older ones |
477 |
|
use kvm_uread, and newer use kvm_read */ |
478 |
|
|
479 |
|
/* if ((pinfo [0].kp_proc.p_flag & P_INMEM) && |
480 |
kvm_uread (kvm_handle, &(pinfo [0]).kp_proc, |
kvm_uread (kvm_handle, &(pinfo [0]).kp_proc, |
481 |
(unsigned long) &u_addr->u_stats, |
(unsigned long) &u_addr->u_stats, |
482 |
(char *) &pstats, sizeof (pstats)) == sizeof (pstats)) { |
(char *) &pstats, sizeof (pstats)) == sizeof (pstats)) { |
483 |
|
*/ |
484 |
rup = &pstats.p_ru; |
rup = &pstats.p_ru; |
485 |
calcru(&(pinfo [0]).kp_proc, |
calcru(&(pinfo [0]).kp_proc, |
486 |
&rup->ru_utime, &rup->ru_stime, NULL); |
&rup->ru_utime, &rup->ru_stime, NULL); |
498 |
} |
} |
499 |
|
|
500 |
p->cputime_prev= p->cputime; |
p->cputime_prev= p->cputime; |
501 |
p->cputime= ( stat_utime + stat_stime ); |
p->cputime= (int)(( stat_utime + stat_stime ) / 1000); |
502 |
|
|
503 |
if( include_children ) { |
if( include_children ) { |
504 |
|
|
505 |
p->cputime+= ( stat_cutime + stat_cstime ); |
p->cputime+= (int)(( stat_cutime + stat_cstime ) / 1000); |
506 |
|
|
507 |
} |
} |
508 |
|
|
569 |
{ |
{ |
570 |
quad_t totusec; |
quad_t totusec; |
571 |
u_quad_t u, st, ut, it, tot; |
u_quad_t u, st, ut, it, tot; |
572 |
#if (__FreeBSD_version < 300003) |
#if (__FreeBSD_version < 300003) |
573 |
long sec, usec; |
long sec, usec; |
574 |
#endif |
#endif |
575 |
|
|
576 |
|
struct timeval tv; |
577 |
|
|
578 |
st = p->p_sticks; |
st = p->p_sticks; |
579 |
ut = p->p_uticks; |
ut = p->p_uticks; |
580 |
it = p->p_iticks; |
it = p->p_iticks; |
586 |
tot = 1; |
tot = 1; |
587 |
} |
} |
588 |
|
|
589 |
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003) |
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003) |
590 |
totusec = (u_quad_t) p->p_runtime; |
totusec = (u_quad_t) p->p_runtime; |
591 |
#else |
#else |
592 |
sec = p->p_rtime.tv_usec; |
sec = p->p_rtime.tv_usec; |
593 |
usec = p->p_rtime.tv_usec; |
usec = p->p_rtime.tv_usec; |
594 |
|
|
595 |
totusec = (quad_t)sec * 1000000 + usec; |
totusec = (quad_t)sec * 1000000 + usec; |
596 |
#endif |
#endif |
597 |
|
|
598 |
if(totusec < 0) |
if(totusec < 0) |
599 |
{ |
{ |