-
Notifications
You must be signed in to change notification settings - Fork 4
/
cpu_util.h
37 lines (29 loc) · 823 Bytes
/
cpu_util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef CPU_UTIL_H
#define CPU_UTIL_H
#include <unistd.h>
#include "os.h"
struct proc_util {
double user;
double sys;
};
struct cpu_util_stats {
double cpu_time;
double proc_user_time;
double proc_sys_time;
};
struct cpu_util {
int stat_fd;
int proc_stat_fd;
char buffer[1024];
spin_pdr_lock_t lock;
struct cpu_util_stats initial_stats;
};
void cpu_util_init(struct cpu_util *c);
void cpu_util_fini(struct cpu_util *c);
struct cpu_util_stats cpu_util_get_stats(struct cpu_util *c);
struct proc_util cpu_util_get_average(struct cpu_util_stats *prev,
struct cpu_util_stats *curr);
void cpu_util_print_average(char *prefix,
struct cpu_util_stats *prev,
struct cpu_util_stats *curr);
#endif // CPU_UTIL_H