Changeset 9935 in vbox
- Timestamp:
- Jun 25, 2008 4:49:24 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/system.h
r9904 r9935 34 34 #include <iprt/types.h> 35 35 36 #define IPRT_USAGE_MULTIPLIER UINT64_C(1000000000)36 #define IPRT_USAGE_MULTIPLIER UINT64_C(1000000000) 37 37 38 /* This structure holds both computed and raw values of overall CPU load counters. */ 39 typedef struct 38 /** 39 * This structure holds both computed and raw values of overall CPU load counters. 40 * 41 * @todo r=bird: What does these values mean? 42 * 43 * Also, I no longer use 'u32', 'u16', 'u8', 'u64', etc unless this information 44 * is really important for the user. So, unless there is a better prefix just 45 * stick to 'u' here. 46 * 47 * The name of the struct should include the prefix or a shortened 48 * version of it: RTSYSCPUUSAGESTATS 49 * 50 * Also, I'd sugest calling it RTSYSCPULOADSTATS, replacing 'usage' with 'load', 51 * no particular reason, other than that it is easier to read in the (silly) 52 * condensed form we use for typedefs here. 53 * 54 * Finally, I'm wondering how portable this is. I'd like to see what APIs are 55 * available on the important systems (Windows, Solaris, Linux) and compare 56 * the kind of info they return. This should be done in the defect *before* 57 * any of the above, please. 58 */ 59 typedef struct RTSYSCPUUSAGESTATS 40 60 { 41 61 uint32_t u32User; … … 74 94 * 75 95 * @returns Number of logical processors in the system. 96 * 97 * @todo Replaced by RTMpGetOnlineCount / RTMpGetCount, retire this guy. 76 98 */ 77 99 RTDECL(unsigned) RTSystemProcessorGetCount(void); … … 81 103 * 82 104 * @returns Active logical processor mask. (bit 0 == logical cpu 0) 105 * 106 * @todo Replaced by RTMpGetOnlineSet, retire this guy. 83 107 */ 84 108 RTDECL(uint64_t) RTSystemProcessorGetActiveMask(void); … … 86 110 /** 87 111 * Gets the current figures of overall system processor usage. 88 * 89 * @remarks To get meaningful stats this function has to be 112 * 113 * @remarks To get meaningful stats this function has to be 90 114 * called twice with a bit of delay between calls. This 91 115 * is due to the fact that at least two samples of 92 116 * system usage stats are needed to calculate the load. 93 * 117 * 94 118 * @returns IPRT status code. 95 * @param pStats Pointer to the structure that contains the 119 * @param pStats Pointer to the structure that contains the 96 120 * results. Note that this structure is 97 121 * modified with each call to this function and 98 122 * is used to provide both in and out values. 123 * @todo r=bird: Change to RTSystemGetCpuLoadStats. 99 124 */ 100 125 RTDECL(int) RTSystemProcessorGetUsageStats(PRTCPUUSAGESTATS pStats); … … 102 127 /** 103 128 * Gets the current processor usage for a partucilar process. 104 * 105 * @remarks To get meaningful stats this function has to be 129 * 130 * @remarks To get meaningful stats this function has to be 106 131 * called twice with a bit of delay between calls. This 107 132 * is due to the fact that at least two samples of 108 133 * system usage stats are needed to calculate the load. 109 * 134 * 110 135 * @returns IPRT status code. 111 * @param pid VM process id. 112 * @param pStats Pointer to the structure that contains the 136 * @param pid VM process id. 137 * @param pStats Pointer to the structure that contains the 113 138 * results. Note that this structure is 114 139 * modified with each call to this function and 115 140 * is used to provide both in and out values. 116 * 117 * @todo Perharps this function should be moved somewhere 141 * 142 * @todo Perharps this function should be moved somewhere 118 143 * else. 144 * @todo r=bird: Yes is should, iprt/proc.h. RTProcGetCpuLoadStats. 119 145 */ 120 146 RTDECL(int) RTProcessGetProcessorUsageStats(RTPROCESS pid, PRTPROCCPUUSAGESTATS pStats); -
trunk/src/VBox/Runtime/r3/posix/system-posix.cpp
r9904 r9935 94 94 /** 95 95 * Gets the current figures of overall system processor usage. 96 * 97 * @remarks To get meaningful stats this function has to be 96 * 97 * @remarks To get meaningful stats this function has to be 98 98 * called twice with a bit of delay between calls. This 99 99 * is due to the fact that at least two samples of 100 100 * system usage stats are needed to calculate the load. 101 * 101 * 102 102 * @returns None. 103 103 */ 104 104 RTDECL(int) RTSystemProcessorGetUsageStats(PRTCPUUSAGESTATS pStats) 105 105 { 106 /** @todo r=bird: This is Linux specific and doesn't belong here. Move this to r3/linux/RTSystemGetCpuLoadStats-linux.cpp. */ 106 107 int rc = VINF_SUCCESS; 107 108 uint32_t u32UserNow, u32NiceNow, u32SystemNow, u32IdleNow; … … 139 140 /** 140 141 * Gets the current processor usage for a partucilar process. 141 * 142 * @remarks To get meaningful stats this function has to be 142 * 143 * @remarks To get meaningful stats this function has to be 143 144 * called twice with a bit of delay between calls. This 144 145 * is due to the fact that at least two samples of 145 146 * system usage stats are needed to calculate the load. 146 * 147 * 147 148 * @returns None. 148 149 */ … … 153 154 uint32_t u32UserDelta, u32SystemDelta; 154 155 uint64_t u64TotalNow, u64TotalDelta; 156 157 /** @todo r=bird: This is Linux specific and doesn't belong here. Move this to r3/linux/RTSystemGetCpuLoadStats-linux.cpp. */ 155 158 FILE *f = fopen("/proc/stat", "r"); 156 159 157 160 if (f) 158 161 { 159 if (fscanf(f, "cpu %u %u %u %u", &u32UserNow, &u32NiceNow, &u32SystemNow, &u32IdleNow) == 4) 162 if (fscanf(f, "cpu %u %u %u %u", &u32UserNow, &u32NiceNow, &u32SystemNow, &u32IdleNow) == 4) /** @todo 'uint32_t' is not necessarily the same as 'unsigned int'. */ 160 163 { 161 164 char *pszName;
Note:
See TracChangeset
for help on using the changeset viewer.