Machine.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef HEADER_Machine
  2. #define HEADER_Machine
  3. /*
  4. htop - Machine.h
  5. (C) 2023 Red Hat, Inc.
  6. (C) 2004,2005 Hisham H. Muhammad
  7. Released under the GNU GPLv2+, see the COPYING file
  8. in the source distribution for its full text.
  9. */
  10. #include <limits.h>
  11. #include <stdbool.h>
  12. #include <stdint.h>
  13. #include <sys/time.h>
  14. #include <sys/types.h>
  15. #include "Panel.h"
  16. #include "Settings.h"
  17. #include "Table.h"
  18. #include "UsersTable.h"
  19. #ifdef HAVE_LIBHWLOC
  20. #include <hwloc.h>
  21. #endif
  22. #ifndef MAX_NAME
  23. #define MAX_NAME 128
  24. #endif
  25. #ifndef MAX_READ
  26. #define MAX_READ 2048
  27. #endif
  28. typedef unsigned long long int memory_t;
  29. #define MEMORY_MAX ULLONG_MAX
  30. typedef struct Machine_ {
  31. struct Settings_* settings;
  32. struct timeval realtime; /* time of the current sample */
  33. uint64_t realtimeMs; /* current time in milliseconds */
  34. uint64_t monotonicMs; /* same, but from monotonic clock */
  35. uint64_t prevMonotonicMs; /* time in milliseconds from monotonic clock of previous scan */
  36. int64_t iterationsRemaining;
  37. #ifdef HAVE_LIBHWLOC
  38. hwloc_topology_t topology;
  39. bool topologyOk;
  40. #endif
  41. memory_t totalMem;
  42. memory_t usedMem;
  43. memory_t buffersMem;
  44. memory_t cachedMem;
  45. memory_t sharedMem;
  46. memory_t availableMem;
  47. memory_t totalSwap;
  48. memory_t usedSwap;
  49. memory_t cachedSwap;
  50. unsigned int activeCPUs;
  51. unsigned int existingCPUs;
  52. UsersTable* usersTable;
  53. uid_t htopUserId;
  54. uid_t maxUserId; /* recently observed */
  55. uid_t userId; /* selected row user ID */
  56. size_t tableCount;
  57. Table **tables;
  58. Table *activeTable;
  59. Table *processTable;
  60. } Machine;
  61. Machine* Machine_new(UsersTable* usersTable, uid_t userId);
  62. void Machine_init(Machine* this, UsersTable* usersTable, uid_t userId);
  63. void Machine_delete(Machine* this);
  64. void Machine_done(Machine* this);
  65. bool Machine_isCPUonline(const Machine* this, unsigned int id);
  66. void Machine_populateTablesFromSettings(Machine* this, Settings* settings, Table* processTable);
  67. void Machine_setTablesPanel(Machine* this, Panel* panel);
  68. void Machine_scan(Machine* this);
  69. void Machine_scanTables(Machine* this);
  70. #endif