146 address os::Linux::_initial_thread_stack_bottom = NULL; |
146 address os::Linux::_initial_thread_stack_bottom = NULL; |
147 uintptr_t os::Linux::_initial_thread_stack_size = 0; |
147 uintptr_t os::Linux::_initial_thread_stack_size = 0; |
148 |
148 |
149 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL; |
149 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL; |
150 int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL; |
150 int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL; |
151 Mutex* os::Linux::_createThread_lock = NULL; |
|
152 pthread_t os::Linux::_main_thread; |
151 pthread_t os::Linux::_main_thread; |
153 int os::Linux::_page_size = -1; |
152 int os::Linux::_page_size = -1; |
154 bool os::Linux::_supports_fast_thread_cpu_time = false; |
153 bool os::Linux::_supports_fast_thread_cpu_time = false; |
155 uint32_t os::Linux::_os_version = 0; |
|
156 const char * os::Linux::_glibc_version = NULL; |
154 const char * os::Linux::_glibc_version = NULL; |
157 const char * os::Linux::_libpthread_version = NULL; |
155 const char * os::Linux::_libpthread_version = NULL; |
158 |
156 |
159 static jlong initial_time_count=0; |
157 static jlong initial_time_count=0; |
160 |
158 |
1362 jlong os::elapsed_frequency() { |
1360 jlong os::elapsed_frequency() { |
1363 return NANOSECS_PER_SEC; // nanosecond resolution |
1361 return NANOSECS_PER_SEC; // nanosecond resolution |
1364 } |
1362 } |
1365 |
1363 |
1366 bool os::supports_vtime() { return true; } |
1364 bool os::supports_vtime() { return true; } |
1367 bool os::enable_vtime() { return false; } |
|
1368 bool os::vtime_enabled() { return false; } |
|
1369 |
1365 |
1370 double os::elapsedVTime() { |
1366 double os::elapsedVTime() { |
1371 struct rusage usage; |
1367 struct rusage usage; |
1372 int retval = getrusage(RUSAGE_THREAD, &usage); |
1368 int retval = getrusage(RUSAGE_THREAD, &usage); |
1373 if (retval == 0) { |
1369 if (retval == 0) { |
4821 assert(rc == 0, "clock_gettime is expected to return 0 code"); |
4817 assert(rc == 0, "clock_gettime is expected to return 0 code"); |
4822 |
4818 |
4823 return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec; |
4819 return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec; |
4824 } |
4820 } |
4825 |
4821 |
4826 void os::Linux::initialize_os_info() { |
|
4827 assert(_os_version == 0, "OS info already initialized"); |
|
4828 |
|
4829 struct utsname _uname; |
|
4830 |
|
4831 uint32_t major; |
|
4832 uint32_t minor; |
|
4833 uint32_t fix; |
|
4834 |
|
4835 int rc; |
|
4836 |
|
4837 // Kernel version is unknown if |
|
4838 // verification below fails. |
|
4839 _os_version = 0x01000000; |
|
4840 |
|
4841 rc = uname(&_uname); |
|
4842 if (rc != -1) { |
|
4843 |
|
4844 rc = sscanf(_uname.release,"%d.%d.%d", &major, &minor, &fix); |
|
4845 if (rc == 3) { |
|
4846 |
|
4847 if (major < 256 && minor < 256 && fix < 256) { |
|
4848 // Kernel version format is as expected, |
|
4849 // set it overriding unknown state. |
|
4850 _os_version = (major << 16) | |
|
4851 (minor << 8 ) | |
|
4852 (fix << 0 ) ; |
|
4853 } |
|
4854 } |
|
4855 } |
|
4856 } |
|
4857 |
|
4858 uint32_t os::Linux::os_version() { |
|
4859 assert(_os_version != 0, "not initialized"); |
|
4860 return _os_version & 0x00FFFFFF; |
|
4861 } |
|
4862 |
|
4863 bool os::Linux::os_version_is_known() { |
|
4864 assert(_os_version != 0, "not initialized"); |
|
4865 return _os_version & 0x01000000 ? false : true; |
|
4866 } |
|
4867 |
|
4868 ///// |
4822 ///// |
4869 // glibc on Linux platform uses non-documented flag |
4823 // glibc on Linux platform uses non-documented flag |
4870 // to indicate, that some special sort of signal |
4824 // to indicate, that some special sort of signal |
4871 // trampoline is used. |
4825 // trampoline is used. |
4872 // We will never set this flag, and we should |
4826 // We will never set this flag, and we should |
5081 os::strerror(errno)); |
5035 os::strerror(errno)); |
5082 } |
5036 } |
5083 init_page_sizes((size_t) Linux::page_size()); |
5037 init_page_sizes((size_t) Linux::page_size()); |
5084 |
5038 |
5085 Linux::initialize_system_info(); |
5039 Linux::initialize_system_info(); |
5086 |
|
5087 Linux::initialize_os_info(); |
|
5088 |
5040 |
5089 os::Linux::CPUPerfTicks pticks; |
5041 os::Linux::CPUPerfTicks pticks; |
5090 bool res = os::Linux::get_tick_information(&pticks, -1); |
5042 bool res = os::Linux::get_tick_information(&pticks, -1); |
5091 |
5043 |
5092 if (res && pticks.has_steal_ticks) { |
5044 if (res && pticks.has_steal_ticks) { |
5259 if (status != 0) { |
5211 if (status != 0) { |
5260 log_info(os)("os::init_2 setrlimit failed: %s", os::strerror(errno)); |
5212 log_info(os)("os::init_2 setrlimit failed: %s", os::strerror(errno)); |
5261 } |
5213 } |
5262 } |
5214 } |
5263 } |
5215 } |
5264 |
|
5265 // Initialize lock used to serialize thread creation (see os::create_thread) |
|
5266 Linux::set_createThread_lock(new Mutex(Mutex::leaf, "createThread_lock", false)); |
|
5267 |
5216 |
5268 // at-exit methods are called in the reverse order of their registration. |
5217 // at-exit methods are called in the reverse order of their registration. |
5269 // atexit functions are called on return from main or as a result of a |
5218 // atexit functions are called on return from main or as a result of a |
5270 // call to exit(3C). There can be only 32 of these functions registered |
5219 // call to exit(3C). There can be only 32 of these functions registered |
5271 // and atexit() does not set errno. |
5220 // and atexit() does not set errno. |
5461 buf[sizeof(buf) - 1] = '\0'; |
5410 buf[sizeof(buf) - 1] = '\0'; |
5462 const int rc = Linux::_pthread_setname_np(pthread_self(), buf); |
5411 const int rc = Linux::_pthread_setname_np(pthread_self(), buf); |
5463 // ERANGE should not happen; all other errors should just be ignored. |
5412 // ERANGE should not happen; all other errors should just be ignored. |
5464 assert(rc != ERANGE, "pthread_setname_np failed"); |
5413 assert(rc != ERANGE, "pthread_setname_np failed"); |
5465 } |
5414 } |
5466 } |
|
5467 |
|
5468 bool os::distribute_processes(uint length, uint* distribution) { |
|
5469 // Not yet implemented. |
|
5470 return false; |
|
5471 } |
5415 } |
5472 |
5416 |
5473 bool os::bind_to_processor(uint processor_id) { |
5417 bool os::bind_to_processor(uint processor_id) { |
5474 // Not yet implemented. |
5418 // Not yet implemented. |
5475 return false; |
5419 return false; |