1 | /** @file
|
---|
2 | * IPRT - System.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | *
|
---|
25 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___iprt_system_h
|
---|
31 | #define ___iprt_system_h
|
---|
32 |
|
---|
33 | #include <iprt/cdefs.h>
|
---|
34 | #include <iprt/types.h>
|
---|
35 |
|
---|
36 | #define IPRT_USAGE_MULTIPLIER UINT64_C(1000000000)
|
---|
37 |
|
---|
38 | /* This structure holds both computed and raw values of overall CPU load counters. */
|
---|
39 | typedef 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;
|
---|
50 | typedef RTCPUUSAGESTATS *PRTCPUUSAGESTATS;
|
---|
51 |
|
---|
52 | /* This structure holds both computed and raw values of per-VM CPU load counters. */
|
---|
53 | typedef 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;
|
---|
62 | typedef RTPROCCPUUSAGESTATS *PRTPROCCPUUSAGESTATS;
|
---|
63 |
|
---|
64 |
|
---|
65 | __BEGIN_DECLS
|
---|
66 |
|
---|
67 | /** @defgroup grp_rt_system RTSystem - System Information
|
---|
68 | * @ingroup grp_rt
|
---|
69 | * @{
|
---|
70 | */
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Gets the number of logical (not physical) processors in the system.
|
---|
74 | *
|
---|
75 | * @returns Number of logical processors in the system.
|
---|
76 | */
|
---|
77 | RTDECL(unsigned) RTSystemProcessorGetCount(void);
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Gets the active logical processor mask.
|
---|
81 | *
|
---|
82 | * @returns Active logical processor mask. (bit 0 == logical cpu 0)
|
---|
83 | */
|
---|
84 | RTDECL(uint64_t) RTSystemProcessorGetActiveMask(void);
|
---|
85 |
|
---|
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 | */
|
---|
100 | RTDECL(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 | */
|
---|
120 | RTDECL(int) RTProcessGetProcessorUsageStats(RTPROCESS pid, PRTPROCCPUUSAGESTATS pStats);
|
---|
121 |
|
---|
122 | /** @} */
|
---|
123 |
|
---|
124 | __END_DECLS
|
---|
125 |
|
---|
126 | #endif
|
---|
127 |
|
---|