VirtualBox

Changeset 9904 in vbox for trunk/include/iprt/system.h


Ignore:
Timestamp:
Jun 25, 2008 11:03:03 AM (16 years ago)
Author:
vboxsync
Message:

Global and per-VM CPU usage API added

File:
1 edited

Legend:

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

    r8245 r9904  
    3434#include <iprt/types.h>
    3535
     36#define IPRT_USAGE_MULTIPLIER UINT64_C(1000000000)
     37
     38/* This structure holds both computed and raw values of overall CPU load counters. */
     39typedef struct
     40{
     41    uint32_t u32User;
     42    uint32_t u32System;
     43    uint32_t u32Idle;
     44    /* Internal raw counter values. */
     45    uint32_t u32RawUser;
     46    uint32_t u32RawNice;
     47    uint32_t u32RawSystem;
     48    uint32_t u32RawIdle;
     49} RTCPUUSAGESTATS;
     50typedef RTCPUUSAGESTATS *PRTCPUUSAGESTATS;
     51
     52/* This structure holds both computed and raw values of per-VM CPU load counters. */
     53typedef struct
     54{
     55    uint32_t u32User;
     56    uint32_t u32System;
     57    /* Internal raw counter values. */
     58    uint64_t u64RawTotal;
     59    uint32_t u32RawProcUser;
     60    uint32_t u32RawProcSystem;
     61} RTPROCCPUUSAGESTATS;
     62typedef RTPROCCPUUSAGESTATS *PRTPROCCPUUSAGESTATS;
     63
    3664
    3765__BEGIN_DECLS
     
    5684RTDECL(uint64_t) RTSystemProcessorGetActiveMask(void);
    5785
     86/**
     87 * Gets the current figures of overall system processor usage.
     88 * 
     89 * @remarks To get meaningful stats this function has to be
     90 *          called twice with a bit of delay between calls. This
     91 *          is due to the fact that at least two samples of
     92 *          system usage stats are needed to calculate the load.
     93 * 
     94 * @returns IPRT status code.
     95 * @param   pStats  Pointer to the structure that contains the
     96 *                  results. Note that this structure is
     97 *                  modified with each call to this function and
     98 *                  is used to provide both in and out values.
     99 */
     100RTDECL(int) RTSystemProcessorGetUsageStats(PRTCPUUSAGESTATS pStats);
     101
     102/**
     103 * Gets the current processor usage for a partucilar process.
     104 * 
     105 * @remarks To get meaningful stats this function has to be
     106 *          called twice with a bit of delay between calls. This
     107 *          is due to the fact that at least two samples of
     108 *          system usage stats are needed to calculate the load.
     109 * 
     110 * @returns IPRT status code.
     111 * @param   pid     VM process id.
     112 * @param   pStats  Pointer to the structure that contains the
     113 *                  results. Note that this structure is
     114 *                  modified with each call to this function and
     115 *                  is used to provide both in and out values.
     116 * 
     117 * @todo    Perharps this function should be moved somewhere
     118 *          else.
     119 */
     120RTDECL(int) RTProcessGetProcessorUsageStats(RTPROCESS pid, PRTPROCCPUUSAGESTATS pStats);
    58121
    59122/** @} */
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