< prev index next >

src/hotspot/os/solaris/os_solaris.cpp

Print this page




 725 
 726 // Thread start routine for all newly created threads
 727 extern "C" void* thread_native_entry(void* thread_addr) {
 728   // Try to randomize the cache line index of hot stack frames.
 729   // This helps when threads of the same stack traces evict each other's
 730   // cache lines. The threads can be either from the same JVM instance, or
 731   // from different JVM instances. The benefit is especially true for
 732   // processors with hyperthreading technology.
 733   static int counter = 0;
 734   int pid = os::current_process_id();
 735   alloca(((pid ^ counter++) & 7) * 128);
 736 
 737   int prio;
 738   Thread* thread = (Thread*)thread_addr;
 739 
 740   thread->initialize_thread_current();
 741 
 742   OSThread* osthr = thread->osthread();
 743 
 744   osthr->set_lwp_id(_lwp_self());  // Store lwp in case we are bound
 745   thread->_schedctl = (void *) schedctl_init();
 746 
 747   log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").",
 748     os::current_thread_id());
 749 
 750   if (UseNUMA) {
 751     int lgrp_id = os::numa_get_group_id();
 752     if (lgrp_id != -1) {
 753       thread->set_lgrp_id(lgrp_id);
 754     }
 755   }
 756 
 757   // Our priority was set when we were created, and stored in the
 758   // osthread, but couldn't be passed through to our LWP until now.
 759   // So read back the priority and set it again.
 760 
 761   if (osthr->thread_id() != -1) {
 762     if (UseThreadPriorities) {
 763       int prio = osthr->native_priority();
 764       if (ThreadPriorityVerbose) {
 765         tty->print_cr("Starting Thread " INTPTR_FORMAT ", LWP is "


 795   if (Thread::current_or_null_safe() != NULL) {
 796     assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
 797     thread->clear_thread_current();
 798   }
 799 
 800   if (UseDetachedThreads) {
 801     thr_exit(NULL);
 802     ShouldNotReachHere();
 803   }
 804   return NULL;
 805 }
 806 
 807 static OSThread* create_os_thread(Thread* thread, thread_t thread_id) {
 808   // Allocate the OSThread object
 809   OSThread* osthread = new OSThread(NULL, NULL);
 810   if (osthread == NULL) return NULL;
 811 
 812   // Store info on the Solaris thread into the OSThread
 813   osthread->set_thread_id(thread_id);
 814   osthread->set_lwp_id(_lwp_self());
 815   thread->_schedctl = (void *) schedctl_init();
 816 
 817   if (UseNUMA) {
 818     int lgrp_id = os::numa_get_group_id();
 819     if (lgrp_id != -1) {
 820       thread->set_lgrp_id(lgrp_id);
 821     }
 822   }
 823 
 824   if (ThreadPriorityVerbose) {
 825     tty->print_cr("In create_os_thread, Thread " INTPTR_FORMAT ", LWP is " INTPTR_FORMAT "\n",
 826                   osthread->thread_id(), osthread->lwp_id());
 827   }
 828 
 829   // Initial thread state is INITIALIZED, not SUSPENDED
 830   osthread->set_state(INITIALIZED);
 831 
 832   return osthread;
 833 }
 834 
 835 void os::Solaris::hotspot_sigmask(Thread* thread) {


3388                                             newpri, myClass, false);
3389   }
3390   status |= lwp_status;
3391   return (status == 0) ? OS_OK : OS_ERR;
3392 }
3393 
3394 
3395 OSReturn os::get_native_priority(const Thread* const thread,
3396                                  int *priority_ptr) {
3397   int p;
3398   if (!UseThreadPriorities) {
3399     *priority_ptr = NormalPriority;
3400     return OS_OK;
3401   }
3402   int status = thr_getprio(thread->osthread()->thread_id(), &p);
3403   if (status != 0) {
3404     return OS_ERR;
3405   }
3406   *priority_ptr = p;
3407   return OS_OK;
3408 }
3409 
3410 
3411 // Hint to the underlying OS that a task switch would not be good.
3412 // Void return because it's a hint and can fail.
3413 void os::hint_no_preempt() {
3414   schedctl_start(schedctl_init());
3415 }
3416 
3417 ////////////////////////////////////////////////////////////////////////////////
3418 // suspend/resume support
3419 
3420 //  The low-level signal-based suspend/resume support is a remnant from the
3421 //  old VM-suspension that used to be for java-suspension, safepoints etc,
3422 //  within hotspot. Currently used by JFR's OSThreadSampler
3423 //
3424 //  The remaining code is greatly simplified from the more general suspension
3425 //  code that used to be used.
3426 //
3427 //  The protocol is quite simple:
3428 //  - suspend:
3429 //      - sends a signal to the target thread
3430 //      - polls the suspend state of the osthread using a yield loop
3431 //      - target thread signal handler (SR_handler) sets suspend state
3432 //        and blocks in sigsuspend until continued
3433 //  - resume:
3434 //      - sets target osthread state to continue




 725 
 726 // Thread start routine for all newly created threads
 727 extern "C" void* thread_native_entry(void* thread_addr) {
 728   // Try to randomize the cache line index of hot stack frames.
 729   // This helps when threads of the same stack traces evict each other's
 730   // cache lines. The threads can be either from the same JVM instance, or
 731   // from different JVM instances. The benefit is especially true for
 732   // processors with hyperthreading technology.
 733   static int counter = 0;
 734   int pid = os::current_process_id();
 735   alloca(((pid ^ counter++) & 7) * 128);
 736 
 737   int prio;
 738   Thread* thread = (Thread*)thread_addr;
 739 
 740   thread->initialize_thread_current();
 741 
 742   OSThread* osthr = thread->osthread();
 743 
 744   osthr->set_lwp_id(_lwp_self());  // Store lwp in case we are bound

 745 
 746   log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").",
 747     os::current_thread_id());
 748 
 749   if (UseNUMA) {
 750     int lgrp_id = os::numa_get_group_id();
 751     if (lgrp_id != -1) {
 752       thread->set_lgrp_id(lgrp_id);
 753     }
 754   }
 755 
 756   // Our priority was set when we were created, and stored in the
 757   // osthread, but couldn't be passed through to our LWP until now.
 758   // So read back the priority and set it again.
 759 
 760   if (osthr->thread_id() != -1) {
 761     if (UseThreadPriorities) {
 762       int prio = osthr->native_priority();
 763       if (ThreadPriorityVerbose) {
 764         tty->print_cr("Starting Thread " INTPTR_FORMAT ", LWP is "


 794   if (Thread::current_or_null_safe() != NULL) {
 795     assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
 796     thread->clear_thread_current();
 797   }
 798 
 799   if (UseDetachedThreads) {
 800     thr_exit(NULL);
 801     ShouldNotReachHere();
 802   }
 803   return NULL;
 804 }
 805 
 806 static OSThread* create_os_thread(Thread* thread, thread_t thread_id) {
 807   // Allocate the OSThread object
 808   OSThread* osthread = new OSThread(NULL, NULL);
 809   if (osthread == NULL) return NULL;
 810 
 811   // Store info on the Solaris thread into the OSThread
 812   osthread->set_thread_id(thread_id);
 813   osthread->set_lwp_id(_lwp_self());

 814 
 815   if (UseNUMA) {
 816     int lgrp_id = os::numa_get_group_id();
 817     if (lgrp_id != -1) {
 818       thread->set_lgrp_id(lgrp_id);
 819     }
 820   }
 821 
 822   if (ThreadPriorityVerbose) {
 823     tty->print_cr("In create_os_thread, Thread " INTPTR_FORMAT ", LWP is " INTPTR_FORMAT "\n",
 824                   osthread->thread_id(), osthread->lwp_id());
 825   }
 826 
 827   // Initial thread state is INITIALIZED, not SUSPENDED
 828   osthread->set_state(INITIALIZED);
 829 
 830   return osthread;
 831 }
 832 
 833 void os::Solaris::hotspot_sigmask(Thread* thread) {


3386                                             newpri, myClass, false);
3387   }
3388   status |= lwp_status;
3389   return (status == 0) ? OS_OK : OS_ERR;
3390 }
3391 
3392 
3393 OSReturn os::get_native_priority(const Thread* const thread,
3394                                  int *priority_ptr) {
3395   int p;
3396   if (!UseThreadPriorities) {
3397     *priority_ptr = NormalPriority;
3398     return OS_OK;
3399   }
3400   int status = thr_getprio(thread->osthread()->thread_id(), &p);
3401   if (status != 0) {
3402     return OS_ERR;
3403   }
3404   *priority_ptr = p;
3405   return OS_OK;







3406 }
3407 
3408 ////////////////////////////////////////////////////////////////////////////////
3409 // suspend/resume support
3410 
3411 //  The low-level signal-based suspend/resume support is a remnant from the
3412 //  old VM-suspension that used to be for java-suspension, safepoints etc,
3413 //  within hotspot. Currently used by JFR's OSThreadSampler
3414 //
3415 //  The remaining code is greatly simplified from the more general suspension
3416 //  code that used to be used.
3417 //
3418 //  The protocol is quite simple:
3419 //  - suspend:
3420 //      - sends a signal to the target thread
3421 //      - polls the suspend state of the osthread using a yield loop
3422 //      - target thread signal handler (SR_handler) sets suspend state
3423 //        and blocks in sigsuspend until continued
3424 //  - resume:
3425 //      - sets target osthread state to continue


< prev index next >