Changeset 10481 in vbox
- Timestamp:
- Jul 10, 2008 7:58:15 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/linux/mp-linux.cpp
r10470 r10481 110 110 strcpy(szFilename, "/sys/"); 111 111 size_t cch = RTStrPrintfV(&szFilename[cchPrefix], sizeof(szFilename) - cchPrefix, pszFormat, va); 112 NOREF(cch); 113 Assert(cch < sizeof(szFilename) - cchPrefix - 1); 112 Assert(cch < sizeof(szFilename) - cchPrefix - 1); NOREF(cch); 114 113 115 114 return open(szFilename, O_RDONLY, 0); … … 249 248 static uint32_t rtMpLinuxGetFrequency(RTCPUID idCpu) 250 249 { 251 FILE * f= fopen("/proc/cpuinfo", "r");252 if (! f)250 FILE *pFile = fopen("/proc/cpuinfo", "r"); 251 if (!pFile) 253 252 return 0; 254 253 255 254 char sz[256]; 256 char *psz = NULL;257 255 RTCPUID idCpuFound = NIL_RTCPUID; 258 uint32_t freq = 0; 259 while (fgets(sz, sizeof(sz), f)) 260 { 256 uint32_t Frequency = 0; 257 while (fgets(sz, sizeof(sz), pFile)) 258 { 259 char *psz; 261 260 if ( !strncmp(sz, "processor", 9) 262 261 && (sz[10] == ' ' || sz[10] == '\t' || sz[10] == ':') … … 279 278 if (RT_SUCCESS(rc)) 280 279 { 281 freq= v;280 Frequency = v; 282 281 break; 283 282 } 284 283 } 285 284 } 286 fclose( f);287 return freq;285 fclose(pFile); 286 return Frequency; 288 287 } 289 288 … … 375 374 if (kHz == -1) 376 375 { 377 /* The file may be just unreadable - in that case use plan B, i.e. 376 /* 377 * The file may be just unreadable - in that case use plan B, i.e. 378 378 * /proc/cpuinfo to get the data we want. The assumption is that if 379 379 * cpuinfo_cur_freq doesn't exist then the speed won't change, and 380 380 * thus cur == max. If it does exist then cpuinfo contains the 381 * current frequency. */ 381 * current frequency. 382 */ 382 383 kHz = rtMpLinuxGetFrequency(idCpu) * 1000; 383 384 } … … 391 392 if (kHz == -1) 392 393 { 393 /* Check if the file isn't there - if it is there, then /proc/cpuinfo 394 * would provide current frequency information, which is wrong. */ 394 /* 395 * Check if the file isn't there - if it is there, then /proc/cpuinfo 396 * would provide current frequency information, which is wrong. 397 */ 395 398 if (!rtLinuxSysFsExists("devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", (int)idCpu)) 396 399 kHz = rtMpLinuxGetFrequency(idCpu) * 1000;
Note:
See TracChangeset
for help on using the changeset viewer.