procinfo.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // This file is part of BOINC.
  2. // http://boinc.berkeley.edu
  3. // Copyright (C) 2008 University of California
  4. //
  5. // BOINC is free software; you can redistribute it and/or modify it
  6. // under the terms of the GNU Lesser General Public License
  7. // as published by the Free Software Foundation,
  8. // either version 3 of the License, or (at your option) any later version.
  9. //
  10. // BOINC is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. // See the GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with BOINC. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef BOINC_PROCINFO_H
  18. #define BOINC_PROCINFO_H
  19. #include <vector>
  20. #include <map>
  21. struct PROCINFO {
  22. int id;
  23. int parentid;
  24. double swap_size;
  25. double working_set_size;
  26. double working_set_size_smoothed;
  27. unsigned long page_fault_count;
  28. double user_time;
  29. double kernel_time;
  30. bool is_boinc_app;
  31. bool is_low_priority;
  32. // running at or below priority of BOINC apps
  33. char command[256];
  34. bool scanned;
  35. double page_fault_rate; // derived by higher-level code
  36. std::vector<int> children;
  37. PROCINFO() {
  38. clear();
  39. working_set_size_smoothed = 0;
  40. }
  41. void clear() {
  42. id = 0;
  43. parentid = 0;
  44. swap_size = 0;
  45. working_set_size = 0;
  46. //working_set_size_smoothed = 0;
  47. // *Don't* clear this
  48. page_fault_count = 0;
  49. user_time = 0;
  50. kernel_time = 0;
  51. is_boinc_app = false;
  52. is_low_priority = false;
  53. command[0] = 0;
  54. scanned = false;
  55. page_fault_rate = 0;
  56. children.clear();
  57. }
  58. };
  59. typedef std::map<int, PROCINFO> PROC_MAP;
  60. extern void find_children(PROC_MAP&);
  61. // fill in the children fields
  62. extern int procinfo_setup(PROC_MAP&);
  63. // call this first to get data structure
  64. extern void procinfo_app(
  65. PROCINFO&, std::vector<int>* other_pids, PROC_MAP&, char* graphics_exec_file
  66. );
  67. // get info for a given app, and mark processes as BOINC
  68. extern void procinfo_non_boinc(PROCINFO&, PROC_MAP&);
  69. // After getting info for all BOINC apps,
  70. // call this to get info for everything else
  71. extern double process_tree_cpu_time(int pid);
  72. // get the CPU time of the given process and its descendants
  73. #endif