src/os/linux/vm/os_linux.cpp

Print this page
rev 3492 : imported patch linux_thread_name.patch


4327 void os::make_polling_page_unreadable(void) {
4328   if( !guard_memory((char*)_polling_page, Linux::page_size()) )
4329     fatal("Could not disable polling page");
4330 };
4331 
4332 // Mark the polling page as readable
4333 void os::make_polling_page_readable(void) {
4334   if( !linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) {
4335     fatal("Could not enable polling page");
4336   }
4337 };
4338 
4339 int os::active_processor_count() {
4340   // Linux doesn't yet have a (official) notion of processor sets,
4341   // so just return the number of online processors.
4342   int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
4343   assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
4344   return online_cpus;
4345 }
4346 


4347 void os::set_native_thread_name(const char *name) {
4348   // Not yet implemented.
4349   return;





4350 }
4351 
4352 bool os::distribute_processes(uint length, uint* distribution) {
4353   // Not yet implemented.
4354   return false;
4355 }
4356 
4357 bool os::bind_to_processor(uint processor_id) {
4358   // Not yet implemented.
4359   return false;
4360 }
4361 
4362 ///
4363 
4364 // Suspends the target using the signal mechanism and then grabs the PC before
4365 // resuming the target. Used by the flat-profiler only
4366 ExtendedPC os::get_thread_pc(Thread* thread) {
4367   // Make sure that it is called by the watcher for the VMThread
4368   assert(Thread::current()->is_Watcher_thread(), "Must be watcher");
4369   assert(thread->is_VM_thread(), "Can only be called for VMThread");




4327 void os::make_polling_page_unreadable(void) {
4328   if( !guard_memory((char*)_polling_page, Linux::page_size()) )
4329     fatal("Could not disable polling page");
4330 };
4331 
4332 // Mark the polling page as readable
4333 void os::make_polling_page_readable(void) {
4334   if( !linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) {
4335     fatal("Could not enable polling page");
4336   }
4337 };
4338 
4339 int os::active_processor_count() {
4340   // Linux doesn't yet have a (official) notion of processor sets,
4341   // so just return the number of online processors.
4342   int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
4343   assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
4344   return online_cpus;
4345 }
4346 
4347 #define MAXTHREADNAMESIZE 16
4348 
4349 void os::set_native_thread_name(const char *name) {
4350   if (name != NULL) {
4351     // The maximum length is 16 (including the trailing \0), we copy
4352     // the first 15 chars into the buffer.
4353     char buf[MAXTHREADNAMESIZE];
4354     snprintf(buf, sizeof(buf), "%s", name);
4355     pthread_setname_np(pthread_self(), buf);
4356   }
4357 }
4358 
4359 bool os::distribute_processes(uint length, uint* distribution) {
4360   // Not yet implemented.
4361   return false;
4362 }
4363 
4364 bool os::bind_to_processor(uint processor_id) {
4365   // Not yet implemented.
4366   return false;
4367 }
4368 
4369 ///
4370 
4371 // Suspends the target using the signal mechanism and then grabs the PC before
4372 // resuming the target. Used by the flat-profiler only
4373 ExtendedPC os::get_thread_pc(Thread* thread) {
4374   // Make sure that it is called by the watcher for the VMThread
4375   assert(Thread::current()->is_Watcher_thread(), "Must be watcher");
4376   assert(thread->is_VM_thread(), "Can only be called for VMThread");