thread_cpu impl

This commit is contained in:
Doug MacEachern 2004-11-17 05:50:18 +00:00
parent cf93196a8a
commit 65fe21ae2b
3 changed files with 51 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#include "sigar_util.h"
#include <sys/dk.h>
#include <sys/lwp.h>
#include <errno.h>
int sigar_os_open(sigar_t **sigar)
@ -439,13 +440,28 @@ int sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
return SIGAR_ENOTIMPL;
}
#define TIME_NSEC(t) \
(SIGAR_SEC2NANO((t).tv_sec) + (sigar_uint64_t)(t).tv_nsec)
int sigar_thread_cpu_get(sigar_t *sigar,
sigar_uint64_t id,
sigar_thread_cpu_t *cpu)
{
struct lwpinfo info;
if (id != 0) {
return SIGAR_ENOTIMPL;
}
_lwp_info(&info);
cpu->user = TIME_NSEC(info.lwp_utime);
cpu->sys = TIME_NSEC(info.lwp_stime);
cpu->total = TIME_NSEC(info.lwp_utime) + TIME_NSEC(info.lwp_stime);
return SIGAR_OK;
}
#include <mntent.h>
int sigar_os_fs_type_get(sigar_file_system_t *fsp)

View File

@ -4,6 +4,7 @@
#include <errno.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/times.h>
#include "sigar.h"
#include "sigar_private.h"
@ -899,13 +900,28 @@ int sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
return SIGAR_OK;
}
#define TIME_NSEC(t) \
SIGAR_SEC2NANO(((sigar_uint64_t)(t) / sigar->ticks))
int sigar_thread_cpu_get(sigar_t *sigar,
sigar_uint64_t id,
sigar_thread_cpu_t *cpu)
{
struct tms now;
if (id != 0) {
return SIGAR_ENOTIMPL;
}
times(&now);
cpu->user = TIME_NSEC(now.tms_utime);
cpu->sys = TIME_NSEC(now.tms_stime);
cpu->total = TIME_NSEC(now.tms_utime + now.tms_stime);
return SIGAR_OK;
}
#include <mntent.h>
#include <sys/statfs.h>

View File

@ -4,6 +4,7 @@
#include "sigar_util.h"
#include <sys/link.h>
#include <sys/lwp.h>
#include <sys/proc.h>
#include <sys/swap.h>
#include <sys/stat.h>
@ -1038,13 +1039,28 @@ int sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
}
}
#define TIME_NSEC(t) \
(SIGAR_SEC2NANO((t).tv_sec) + (sigar_uint64_t)(t).tv_nsec)
int sigar_thread_cpu_get(sigar_t *sigar,
sigar_uint64_t id,
sigar_thread_cpu_t *cpu)
{
struct lwpinfo info;
if (id != 0) {
return SIGAR_ENOTIMPL;
}
_lwp_info(&info);
cpu->user = TIME_NSEC(info.lwp_utime);
cpu->sys = TIME_NSEC(info.lwp_stime);
cpu->total = TIME_NSEC(info.lwp_utime) + TIME_NSEC(info.lwp_stime);
return SIGAR_OK;
}
#include <sys/mnttab.h>
int sigar_os_fs_type_get(sigar_file_system_t *fsp)