VirtualBox

Changeset 9935 in vbox


Ignore:
Timestamp:
Jun 25, 2008 4:49:24 PM (17 years ago)
Author:
vboxsync
Message:

r=bird: Review comments, work to be done. Marked the RTSystemProcessorGetCount/ActiveMask as retired by the RTMp stuff (partly a todo).

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/system.h

    r9904 r9935  
    3434#include <iprt/types.h>
    3535
    36 #define IPRT_USAGE_MULTIPLIER UINT64_C(1000000000)
     36#define IPRT_USAGE_MULTIPLIER   UINT64_C(1000000000)
    3737
    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 */
     59typedef struct RTSYSCPUUSAGESTATS
    4060{
    4161    uint32_t u32User;
     
    7494 *
    7595 * @returns Number of logical processors in the system.
     96 *
     97 * @todo Replaced by RTMpGetOnlineCount / RTMpGetCount, retire this guy.
    7698 */
    7799RTDECL(unsigned) RTSystemProcessorGetCount(void);
     
    81103 *
    82104 * @returns Active logical processor mask. (bit 0 == logical cpu 0)
     105 *
     106 * @todo Replaced by RTMpGetOnlineSet, retire this guy.
    83107 */
    84108RTDECL(uint64_t) RTSystemProcessorGetActiveMask(void);
     
    86110/**
    87111 * 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
    90114 *          called twice with a bit of delay between calls. This
    91115 *          is due to the fact that at least two samples of
    92116 *          system usage stats are needed to calculate the load.
    93  * 
     117 *
    94118 * @returns IPRT status code.
    95  * @param   pStats  Pointer to the structure that contains the 
     119 * @param   pStats  Pointer to the structure that contains the
    96120 *                  results. Note that this structure is
    97121 *                  modified with each call to this function and
    98122 *                  is used to provide both in and out values.
     123 * @todo r=bird: Change to RTSystemGetCpuLoadStats.
    99124 */
    100125RTDECL(int) RTSystemProcessorGetUsageStats(PRTCPUUSAGESTATS pStats);
     
    102127/**
    103128 * 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
    106131 *          called twice with a bit of delay between calls. This
    107132 *          is due to the fact that at least two samples of
    108133 *          system usage stats are needed to calculate the load.
    109  * 
     134 *
    110135 * @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
    113138 *                  results. Note that this structure is
    114139 *                  modified with each call to this function and
    115140 *                  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
    118143 *          else.
     144 * @todo    r=bird: Yes is should, iprt/proc.h. RTProcGetCpuLoadStats.
    119145 */
    120146RTDECL(int) RTProcessGetProcessorUsageStats(RTPROCESS pid, PRTPROCCPUUSAGESTATS pStats);
  • trunk/src/VBox/Runtime/r3/posix/system-posix.cpp

    r9904 r9935  
    9494/**
    9595 * 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
    9898 *          called twice with a bit of delay between calls. This
    9999 *          is due to the fact that at least two samples of
    100100 *          system usage stats are needed to calculate the load.
    101  * 
     101 *
    102102 * @returns None.
    103103 */
    104104RTDECL(int) RTSystemProcessorGetUsageStats(PRTCPUUSAGESTATS pStats)
    105105{
     106/** @todo r=bird: This is Linux specific and doesn't belong here. Move this to r3/linux/RTSystemGetCpuLoadStats-linux.cpp. */
    106107    int rc = VINF_SUCCESS;
    107108    uint32_t u32UserNow, u32NiceNow, u32SystemNow, u32IdleNow;
     
    139140/**
    140141 * 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
    143144 *          called twice with a bit of delay between calls. This
    144145 *          is due to the fact that at least two samples of
    145146 *          system usage stats are needed to calculate the load.
    146  * 
     147 *
    147148 * @returns None.
    148149 */
     
    153154    uint32_t u32UserDelta, u32SystemDelta;
    154155    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. */
    155158    FILE *f = fopen("/proc/stat", "r");
    156159
    157160    if (f)
    158161    {
    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'. */
    160163        {
    161164            char *pszName;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette