14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "jvm.h"
26 #include "memory/allocation.hpp"
27 #include "memory/allocation.inline.hpp"
28 #include "vm_version_ext_sparc.hpp"
29
30 // VM_Version_Ext statics
31 int VM_Version_Ext::_no_of_threads = 0;
32 int VM_Version_Ext::_no_of_cores = 0;
33 int VM_Version_Ext::_no_of_sockets = 0;
34 kid_t VM_Version_Ext::_kcid = -1;
35 char VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
36 char VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
37
38 // get cpu information. It takes into account if the kstat chain id
39 // has been changed and update the info if necessary.
40 bool VM_Version_Ext::initialize_cpu_information(void) {
41
42 int core_id = -1;
43 int chip_id = -1;
44 int len = 0;
45 char* src_string = NULL;
46 kstat_ctl_t* kc = kstat_open();
47 if (!kc) {
48 return false;
49 }
50
51 // check if kstat chain has been updated
52 kid_t kcid = kstat_chain_update(kc);
53 if (kcid == -1) {
54 kstat_close(kc);
55 return false;
56 }
57
127 chip_id = knm[i].value.l;
128 _no_of_sockets++;
129 }
130 }
131
132 // count the number of cores based on the core id
133 if (strcmp((const char*)&(knm[i].name), CORE_ID) == 0) {
134 if (core_id != knm[i].value.l) {
135 core_id = knm[i].value.l;
136 _no_of_cores++;
137 }
138 }
139 }
140 }
141 }
142 }
143
144 kstat_close(kc);
145 return true;
146 }
147
148 int VM_Version_Ext::number_of_threads(void) {
149 initialize_cpu_information();
150 return _no_of_threads;
151 }
152
153 int VM_Version_Ext::number_of_cores(void) {
154 initialize_cpu_information();
155 return _no_of_cores;
156 }
157
158 int VM_Version_Ext::number_of_sockets(void) {
159 initialize_cpu_information();
160 return _no_of_sockets;
161 }
162
163 const char* VM_Version_Ext::cpu_name(void) {
164 if (!initialize_cpu_information()) {
165 return NULL;
166 }
|
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "jvm.h"
26 #include "memory/allocation.hpp"
27 #include "memory/allocation.inline.hpp"
28 #include "vm_version_ext_sparc.hpp"
29
30 // VM_Version_Ext statics
31 int VM_Version_Ext::_no_of_threads = 0;
32 int VM_Version_Ext::_no_of_cores = 0;
33 int VM_Version_Ext::_no_of_sockets = 0;
34 #if defined(SOLARIS)
35 kid_t VM_Version_Ext::_kcid = -1;
36 #endif
37 char VM_Version_Ext::_cpu_name[CPU_TYPE_DESC_BUF_SIZE] = {0};
38 char VM_Version_Ext::_cpu_desc[CPU_DETAILED_DESC_BUF_SIZE] = {0};
39
40 #if defined(SOLARIS)
41 // get cpu information. It takes into account if the kstat chain id
42 // has been changed and update the info if necessary.
43 bool VM_Version_Ext::initialize_cpu_information(void) {
44
45 int core_id = -1;
46 int chip_id = -1;
47 int len = 0;
48 char* src_string = NULL;
49 kstat_ctl_t* kc = kstat_open();
50 if (!kc) {
51 return false;
52 }
53
54 // check if kstat chain has been updated
55 kid_t kcid = kstat_chain_update(kc);
56 if (kcid == -1) {
57 kstat_close(kc);
58 return false;
59 }
60
130 chip_id = knm[i].value.l;
131 _no_of_sockets++;
132 }
133 }
134
135 // count the number of cores based on the core id
136 if (strcmp((const char*)&(knm[i].name), CORE_ID) == 0) {
137 if (core_id != knm[i].value.l) {
138 core_id = knm[i].value.l;
139 _no_of_cores++;
140 }
141 }
142 }
143 }
144 }
145 }
146
147 kstat_close(kc);
148 return true;
149 }
150 #elif defined(LINUX)
151 // get cpu information.
152 bool VM_Version_Ext::initialize_cpu_information(void) {
153 // Not yet implemented.
154 return false;
155 }
156 #endif
157
158 int VM_Version_Ext::number_of_threads(void) {
159 initialize_cpu_information();
160 return _no_of_threads;
161 }
162
163 int VM_Version_Ext::number_of_cores(void) {
164 initialize_cpu_information();
165 return _no_of_cores;
166 }
167
168 int VM_Version_Ext::number_of_sockets(void) {
169 initialize_cpu_information();
170 return _no_of_sockets;
171 }
172
173 const char* VM_Version_Ext::cpu_name(void) {
174 if (!initialize_cpu_information()) {
175 return NULL;
176 }
|