1 #include <glibtop.h> 2 #include <glibtop/procaffinity.h> 3 4 #include <glib.h> 5 #include <unistd.h> 6 main(int argc,char ** argv)7int main(int argc, char **argv) 8 { 9 pid_t pid; 10 glibtop_proc_affinity buf; 11 guint16 *cpus; 12 size_t i; 13 14 if (argc < 2 || !(pid = strtoul(argv[1], NULL, 0))) 15 pid = getpid(); 16 17 glibtop_init(); 18 19 cpus = glibtop_get_proc_affinity(&buf, pid); 20 21 g_print("Process %u:\n" 22 " - all: %d\n", 23 (unsigned)pid, buf.all); 24 25 for (i = 0; i != buf.number; ++i) 26 g_print(" - CPU#%u is set\n", cpus[i]); 27 28 g_free(cpus); 29 30 glibtop_close(); 31 32 return 0; 33 } 34 35