271 }
272
273 julong os::Solaris::_physical_memory = 0;
274
275 julong os::physical_memory() {
276 return Solaris::physical_memory();
277 }
278
279 static hrtime_t first_hrtime = 0;
280 static const hrtime_t hrtime_hz = 1000*1000*1000;
281 static volatile hrtime_t max_hrtime = 0;
282
283
284 void os::Solaris::initialize_system_info() {
285 set_processor_count(sysconf(_SC_NPROCESSORS_CONF));
286 _processors_online = sysconf(_SC_NPROCESSORS_ONLN);
287 _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) *
288 (julong)sysconf(_SC_PAGESIZE);
289 }
290
291 int os::active_processor_count() {
292 int online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
293 pid_t pid = getpid();
294 psetid_t pset = PS_NONE;
295 // Are we running in a processor set or is there any processor set around?
296 if (pset_bind(PS_QUERY, P_PID, pid, &pset) == 0) {
297 uint_t pset_cpus;
298 // Query the number of cpus available to us.
299 if (pset_info(pset, NULL, &pset_cpus, NULL) == 0) {
300 assert(pset_cpus > 0 && pset_cpus <= online_cpus, "sanity check");
301 _processors_online = pset_cpus;
302 return pset_cpus;
303 }
304 }
305 // Otherwise return number of online cpus
306 return online_cpus;
307 }
308
309 static bool find_processors_in_pset(psetid_t pset,
310 processorid_t** id_array,
4347 warning("pset_getloadavg function not found");
4348 }
4349 }
4350
4351 int os::Solaris::_dev_zero_fd = -1;
4352
4353 // this is called _before_ the global arguments have been parsed
4354 void os::init(void) {
4355 _initial_pid = getpid();
4356
4357 max_hrtime = first_hrtime = gethrtime();
4358
4359 init_random(1234567);
4360
4361 page_size = sysconf(_SC_PAGESIZE);
4362 if (page_size == -1) {
4363 fatal("os_solaris.cpp: os::init: sysconf failed (%s)", strerror(errno));
4364 }
4365 init_page_sizes((size_t) page_size);
4366
4367 Solaris::initialize_system_info();
4368
4369 // Initialize misc. symbols as soon as possible, so we can use them
4370 // if we need them.
4371 Solaris::misc_sym_init();
4372
4373 int fd = ::open("/dev/zero", O_RDWR);
4374 if (fd < 0) {
4375 fatal("os::init: cannot open /dev/zero (%s)", strerror(errno));
4376 } else {
4377 Solaris::set_dev_zero_fd(fd);
4378
4379 // Close on exec, child won't inherit.
4380 fcntl(fd, F_SETFD, FD_CLOEXEC);
4381 }
4382
4383 clock_tics_per_sec = CLK_TCK;
4384
4385 // check if dladdr1() exists; dladdr1 can provide more information than
4386 // dladdr for os::dll_address_to_function_name. It comes with SunOS 5.9
4387 // and is available on linker patches for 5.7 and 5.8.
4388 // libdl.so must have been loaded, this call is just an entry lookup
4389 void * hdl = dlopen("libdl.so", RTLD_NOW);
4390 if (hdl) {
4391 dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
4392 }
|
271 }
272
273 julong os::Solaris::_physical_memory = 0;
274
275 julong os::physical_memory() {
276 return Solaris::physical_memory();
277 }
278
279 static hrtime_t first_hrtime = 0;
280 static const hrtime_t hrtime_hz = 1000*1000*1000;
281 static volatile hrtime_t max_hrtime = 0;
282
283
284 void os::Solaris::initialize_system_info() {
285 set_processor_count(sysconf(_SC_NPROCESSORS_CONF));
286 _processors_online = sysconf(_SC_NPROCESSORS_ONLN);
287 _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) *
288 (julong)sysconf(_SC_PAGESIZE);
289 }
290
291
292 void os::Solaris::initialize_features_info() {
293
294 initialize_system_info();
295
296 // Initialize misc. symbols as soon as possible, so we can use them
297 // if we need them.
298 misc_sym_init();
299 }
300
301 int os::active_processor_count() {
302 int online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
303 pid_t pid = getpid();
304 psetid_t pset = PS_NONE;
305 // Are we running in a processor set or is there any processor set around?
306 if (pset_bind(PS_QUERY, P_PID, pid, &pset) == 0) {
307 uint_t pset_cpus;
308 // Query the number of cpus available to us.
309 if (pset_info(pset, NULL, &pset_cpus, NULL) == 0) {
310 assert(pset_cpus > 0 && pset_cpus <= online_cpus, "sanity check");
311 _processors_online = pset_cpus;
312 return pset_cpus;
313 }
314 }
315 // Otherwise return number of online cpus
316 return online_cpus;
317 }
318
319 static bool find_processors_in_pset(psetid_t pset,
320 processorid_t** id_array,
4357 warning("pset_getloadavg function not found");
4358 }
4359 }
4360
4361 int os::Solaris::_dev_zero_fd = -1;
4362
4363 // this is called _before_ the global arguments have been parsed
4364 void os::init(void) {
4365 _initial_pid = getpid();
4366
4367 max_hrtime = first_hrtime = gethrtime();
4368
4369 init_random(1234567);
4370
4371 page_size = sysconf(_SC_PAGESIZE);
4372 if (page_size == -1) {
4373 fatal("os_solaris.cpp: os::init: sysconf failed (%s)", strerror(errno));
4374 }
4375 init_page_sizes((size_t) page_size);
4376
4377 int fd = ::open("/dev/zero", O_RDWR);
4378 if (fd < 0) {
4379 fatal("os::init: cannot open /dev/zero (%s)", strerror(errno));
4380 } else {
4381 Solaris::set_dev_zero_fd(fd);
4382
4383 // Close on exec, child won't inherit.
4384 fcntl(fd, F_SETFD, FD_CLOEXEC);
4385 }
4386
4387 clock_tics_per_sec = CLK_TCK;
4388
4389 // check if dladdr1() exists; dladdr1 can provide more information than
4390 // dladdr for os::dll_address_to_function_name. It comes with SunOS 5.9
4391 // and is available on linker patches for 5.7 and 5.8.
4392 // libdl.so must have been loaded, this call is just an entry lookup
4393 void * hdl = dlopen("libdl.so", RTLD_NOW);
4394 if (hdl) {
4395 dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
4396 }
|