src/os/linux/vm/os_linux.cpp

changeset 9676
bf1c9a3312a4
parent 9620
97d605522fcb
child 9703
2fdf635bcf28
child 9711
0f2fe7d37d8c
equal deleted inserted replaced
9675:894c78fcb2ea 9676:bf1c9a3312a4
134 address os::Linux::_initial_thread_stack_bottom = NULL; 134 address os::Linux::_initial_thread_stack_bottom = NULL;
135 uintptr_t os::Linux::_initial_thread_stack_size = 0; 135 uintptr_t os::Linux::_initial_thread_stack_size = 0;
136 136
137 int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL; 137 int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL;
138 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL; 138 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
139 int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
139 Mutex* os::Linux::_createThread_lock = NULL; 140 Mutex* os::Linux::_createThread_lock = NULL;
140 pthread_t os::Linux::_main_thread; 141 pthread_t os::Linux::_main_thread;
141 int os::Linux::_page_size = -1; 142 int os::Linux::_page_size = -1;
142 const int os::Linux::_vm_default_page_size = (8 * K); 143 const int os::Linux::_vm_default_page_size = (8 * K);
143 bool os::Linux::_is_floating_stack = false; 144 bool os::Linux::_is_floating_stack = false;
5052 if (vm_page_size() > (int)Linux::vm_default_page_size()) { 5053 if (vm_page_size() > (int)Linux::vm_default_page_size()) {
5053 StackYellowPages = 1; 5054 StackYellowPages = 1;
5054 StackRedPages = 1; 5055 StackRedPages = 1;
5055 StackShadowPages = round_to((StackShadowPages*Linux::vm_default_page_size()), vm_page_size()) / vm_page_size(); 5056 StackShadowPages = round_to((StackShadowPages*Linux::vm_default_page_size()), vm_page_size()) / vm_page_size();
5056 } 5057 }
5058
5059 // retrieve entry point for pthread_setname_np
5060 Linux::_pthread_setname_np =
5061 (int(*)(pthread_t, const char*))dlsym(RTLD_DEFAULT, "pthread_setname_np");
5062
5057 } 5063 }
5058 5064
5059 // To install functions for atexit system call 5065 // To install functions for atexit system call
5060 extern "C" { 5066 extern "C" {
5061 static void perfMemory_exit_helper() { 5067 static void perfMemory_exit_helper() {
5306 5312
5307 return active_cpus; 5313 return active_cpus;
5308 } 5314 }
5309 5315
5310 void os::set_native_thread_name(const char *name) { 5316 void os::set_native_thread_name(const char *name) {
5311 // Not yet implemented. 5317 if (Linux::_pthread_setname_np) {
5312 return; 5318 char buf [16]; // according to glibc manpage, 16 chars incl. '/0'
5319 snprintf(buf, sizeof(buf), "%s", name);
5320 buf[sizeof(buf) - 1] = '\0';
5321 const int rc = Linux::_pthread_setname_np(pthread_self(), buf);
5322 // ERANGE should not happen; all other errors should just be ignored.
5323 assert(rc != ERANGE, "pthread_setname_np failed");
5324 }
5313 } 5325 }
5314 5326
5315 bool os::distribute_processes(uint length, uint* distribution) { 5327 bool os::distribute_processes(uint length, uint* distribution) {
5316 // Not yet implemented. 5328 // Not yet implemented.
5317 return false; 5329 return false;

mercurial