cpu.h 517 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef CPU_H
  2. #define CPU_H
  3. #include <stdio.h>
  4. #include <inttypes.h>
  5. /*
  6. * see /proc/stat in `man 5 proc`
  7. *
  8. * guest time is already accounted in usertime,
  9. * so skip `guest` and `guest_nice`
  10. */
  11. enum CPU_STATE {
  12. CPU_STATE_USER = 0,
  13. CPU_STATE_NICE = 1,
  14. CPU_STATE_SYSTEM = 2,
  15. CPU_STATE_IDLE = 3,
  16. CPU_STATE_IOWAIT = 4,
  17. CPU_STATE_IRQ = 5,
  18. CPU_STATE_SOFTIRQ = 6,
  19. CPU_STATE_STEAL = 7,
  20. _CPU_STATE_COUNT,
  21. };
  22. struct cpu_data_t {
  23. int fd;
  24. uintmax_t states[_CPU_STATE_COUNT];
  25. };
  26. #endif /* CPU_H */