blob: cd670daee321a7b30881c8df53dfe09d43f16bbe (
plain)
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
|
#include <glibtop.h>
#include <glibtop/procaffinity.h>
#include <glib.h>
#include <unistd.h>
int main(int argc, char **argv)
{
pid_t pid;
glibtop_proc_affinity buf;
guint16 *cpus;
size_t i;
if (argc < 2 || !(pid = strtoul(argv[1], NULL, 0)))
pid = getpid();
glibtop_init();
cpus = glibtop_get_proc_affinity(&buf, pid);
g_print("Process %u:\n"
" - all: %d\n",
(unsigned)pid, buf.all);
for (i = 0; i != buf.number; ++i)
g_print(" - CPU#%u is set\n", cpus[i]);
g_free(cpus);
glibtop_close();
return 0;
}
|