Blame include/glibtop/proctime.h

Packit d37888
/* Copyright (C) 1998-99 Martin Baulig
Packit d37888
   This file is part of LibGTop 1.0.
Packit d37888
Packit d37888
   Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
Packit d37888
Packit d37888
   LibGTop is free software; you can redistribute it and/or modify it
Packit d37888
   under the terms of the GNU General Public License as published by
Packit d37888
   the Free Software Foundation; either version 2 of the License,
Packit d37888
   or (at your option) any later version.
Packit d37888
Packit d37888
   LibGTop is distributed in the hope that it will be useful, but WITHOUT
Packit d37888
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
Packit d37888
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit d37888
   for more details.
Packit d37888
Packit d37888
   You should have received a copy of the GNU General Public License
Packit d37888
   along with LibGTop; see the file COPYING. If not, write to the
Packit d37888
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit d37888
   Boston, MA 02110-1301, USA.
Packit d37888
*/
Packit d37888
Packit d37888
#ifndef __GLIBTOP_PROCTIME_H__
Packit d37888
#define __GLIBTOP_PROCTIME_H__
Packit d37888
Packit d37888
#include <glibtop.h>
Packit d37888
#include <glibtop/cpu.h>
Packit d37888
#include <glibtop/global.h>
Packit d37888
Packit d37888
G_BEGIN_DECLS
Packit d37888
Packit d37888
#define GLIBTOP_PROC_TIME_START_TIME	0
Packit d37888
#define GLIBTOP_PROC_TIME_RTIME		1
Packit d37888
#define GLIBTOP_PROC_TIME_UTIME		2
Packit d37888
#define GLIBTOP_PROC_TIME_STIME		3
Packit d37888
#define GLIBTOP_PROC_TIME_CUTIME	4
Packit d37888
#define GLIBTOP_PROC_TIME_CSTIME	5
Packit d37888
#define GLIBTOP_PROC_TIME_TIMEOUT	6
Packit d37888
#define GLIBTOP_PROC_TIME_IT_REAL_VALUE	7
Packit d37888
#define GLIBTOP_PROC_TIME_FREQUENCY	8
Packit d37888
#define GLIBTOP_PROC_TIME_XCPU_UTIME	9
Packit d37888
#define GLIBTOP_PROC_TIME_XCPU_STIME	10
Packit d37888
Packit d37888
#define GLIBTOP_MAX_PROC_TIME		11
Packit d37888
Packit d37888
typedef struct _glibtop_proc_time	glibtop_proc_time;
Packit d37888
Packit d37888
/* Time section */
Packit d37888
Packit d37888
/**
Packit d37888
 * glibtop_proc_time:
Packit d37888
 * @start_time: Start time of process in seconds since the epoch.
Packit d37888
 * @rtime: Real time accumulated by process (should be @utime + @stime).
Packit d37888
 * @utime: User-mode CPU time accumulated by process.
Packit d37888
 * @stime: Kernel-mode CPU time accumulated by process.
Packit d37888
 * @cutime: Cumulative utime of process and reaped children.
Packit d37888
 * @cstime: Cumulative stime of process and reaped children.
Packit d37888
 * @timeout: The time (in jiffies) of the process’s next timeout.
Packit d37888
 * @it_real_value: The time (in jiffies) before the next <type>SIGALRM</type>
Packit d37888
 * is sent to the process due to an interval timer.
Packit d37888
 * @frequency: Tick frequency.
Packit d37888
 * @xcpu_utime: SMP user-mode CPU time accumulated by process.
Packit d37888
 * @xcpu_stime: SMP kernel-mode CPU time accumulated by process 
Packit d37888
 *
Packit d37888
 * Process time data filled by glibtop_get_proc_time().
Packit d37888
 *
Packit d37888
 * Under Linux the @start_time value may be wrong due to the information
Packit d37888
 * available from the kernel.
Packit d37888
 * 
Packit d37888
 * The Linux kernel defines <type>INITIAL_JIFFIES</type> which implies a time
Packit d37888
 * shift. Because <type>INITIAL_JIFFIES</type> is not user-space defined,
Packit d37888
 * we cannot use it to compute an accurate @start_time. On Linux 2.6,
Packit d37888
 * <type>INITIAL_JIFFIES</type> is 300 so @start_time is 
Packit d37888
 * always 3s different from the real start time of the given process. You 
Packit d37888
 * may also get shift results if your system clock is not synchronised 
Packit d37888
 * with your hardware clock. See <command>man hwclock</command>.
Packit d37888
 */
Packit d37888
struct _glibtop_proc_time
Packit d37888
{
Packit d37888
    /*< private >*/
Packit d37888
	guint64	flags;
Packit d37888
	/*< public >*/
Packit d37888
	guint64 start_time;
Packit d37888
	guint64 rtime;
Packit d37888
	guint64 utime;
Packit d37888
	guint64 stime;
Packit d37888
	guint64 cutime;
Packit d37888
	guint64 cstime;
Packit d37888
	guint64 timeout;
Packit d37888
	guint64 it_real_value;
Packit d37888
	guint64 frequency;
Packit d37888
	guint64 xcpu_utime [GLIBTOP_NCPU];
Packit d37888
	guint64 xcpu_stime [GLIBTOP_NCPU];
Packit d37888
};
Packit d37888
Packit d37888
Packit d37888
void glibtop_get_proc_time(glibtop_proc_time *buf, pid_t pid);
Packit d37888
Packit d37888
#if GLIBTOP_SUID_PROC_TIME
Packit d37888
#define glibtop_get_proc_time_r	glibtop_get_proc_time_p
Packit d37888
#else
Packit d37888
#define glibtop_get_proc_time_r	glibtop_get_proc_time_s
Packit d37888
#endif
Packit d37888
Packit d37888
void glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf, pid_t pid);
Packit d37888
Packit d37888
#if GLIBTOP_SUID_PROC_TIME
Packit d37888
void _glibtop_init_proc_time_p (glibtop *server);
Packit d37888
void glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, pid_t pid);
Packit d37888
#else
Packit d37888
void _glibtop_init_proc_time_s (glibtop *server);
Packit d37888
void glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid);
Packit d37888
#endif
Packit d37888
Packit d37888
Packit d37888
G_END_DECLS
Packit d37888
Packit d37888
#endif