< prev index next >

src/os/solaris/vm/os_solaris.cpp

Print this page




 711 
 712 extern "C" void breakpoint() {
 713   // use debugger to set breakpoint here
 714 }
 715 
 716 static thread_t main_thread;
 717 
 718 // Thread start routine for all new Java threads
 719 extern "C" void* java_start(void* thread_addr) {
 720   // Try to randomize the cache line index of hot stack frames.
 721   // This helps when threads of the same stack traces evict each other's
 722   // cache lines. The threads can be either from the same JVM instance, or
 723   // from different JVM instances. The benefit is especially true for
 724   // processors with hyperthreading technology.
 725   static int counter = 0;
 726   int pid = os::current_process_id();
 727   alloca(((pid ^ counter++) & 7) * 128);
 728 
 729   int prio;
 730   Thread* thread = (Thread*)thread_addr;



 731   OSThread* osthr = thread->osthread();
 732 
 733   osthr->set_lwp_id(_lwp_self());  // Store lwp in case we are bound
 734   thread->_schedctl = (void *) schedctl_init();
 735 
 736   if (UseNUMA) {
 737     int lgrp_id = os::numa_get_group_id();
 738     if (lgrp_id != -1) {
 739       thread->set_lgrp_id(lgrp_id);
 740     }
 741   }
 742 
 743   // If the creator called set priority before we started,
 744   // we need to call set_native_priority now that we have an lwp.
 745   // We used to get the priority from thr_getprio (we called
 746   // thr_setprio way back in create_thread) and pass it to
 747   // set_native_priority, but Solaris scales the priority
 748   // in java_to_os_priority, so when we read it back here,
 749   // we pass trash to set_native_priority instead of what's
 750   // in java_to_os_priority. So we save the native priority


5588     status = os::Solaris::cond_signal(_cond);
5589     assert(status == 0, "invariant");
5590   }
5591 }
5592 
5593 extern char** environ;
5594 
5595 // Run the specified command in a separate process. Return its exit value,
5596 // or -1 on failure (e.g. can't fork a new process).
5597 // Unlike system(), this function can be called from signal handler. It
5598 // doesn't block SIGINT et al.
5599 int os::fork_and_exec(char* cmd) {
5600   char * argv[4];
5601   argv[0] = (char *)"sh";
5602   argv[1] = (char *)"-c";
5603   argv[2] = cmd;
5604   argv[3] = NULL;
5605 
5606   // fork is async-safe, fork1 is not so can't use in signal handler
5607   pid_t pid;
5608   Thread* t = ThreadLocalStorage::get_thread_slow();
5609   if (t != NULL && t->is_inside_signal_handler()) {
5610     pid = fork();
5611   } else {
5612     pid = fork1();
5613   }
5614 
5615   if (pid < 0) {
5616     // fork failed
5617     warning("fork failed: %s", strerror(errno));
5618     return -1;
5619 
5620   } else if (pid == 0) {
5621     // child process
5622 
5623     // try to be consistent with system(), which uses "/usr/bin/sh" on Solaris
5624     execve("/usr/bin/sh", argv, environ);
5625 
5626     // execve failed
5627     _exit(-1);
5628 




 711 
 712 extern "C" void breakpoint() {
 713   // use debugger to set breakpoint here
 714 }
 715 
 716 static thread_t main_thread;
 717 
 718 // Thread start routine for all new Java threads
 719 extern "C" void* java_start(void* thread_addr) {
 720   // Try to randomize the cache line index of hot stack frames.
 721   // This helps when threads of the same stack traces evict each other's
 722   // cache lines. The threads can be either from the same JVM instance, or
 723   // from different JVM instances. The benefit is especially true for
 724   // processors with hyperthreading technology.
 725   static int counter = 0;
 726   int pid = os::current_process_id();
 727   alloca(((pid ^ counter++) & 7) * 128);
 728 
 729   int prio;
 730   Thread* thread = (Thread*)thread_addr;
 731 
 732   thread->initialize_thread_current();
 733 
 734   OSThread* osthr = thread->osthread();
 735 
 736   osthr->set_lwp_id(_lwp_self());  // Store lwp in case we are bound
 737   thread->_schedctl = (void *) schedctl_init();
 738 
 739   if (UseNUMA) {
 740     int lgrp_id = os::numa_get_group_id();
 741     if (lgrp_id != -1) {
 742       thread->set_lgrp_id(lgrp_id);
 743     }
 744   }
 745 
 746   // If the creator called set priority before we started,
 747   // we need to call set_native_priority now that we have an lwp.
 748   // We used to get the priority from thr_getprio (we called
 749   // thr_setprio way back in create_thread) and pass it to
 750   // set_native_priority, but Solaris scales the priority
 751   // in java_to_os_priority, so when we read it back here,
 752   // we pass trash to set_native_priority instead of what's
 753   // in java_to_os_priority. So we save the native priority


5591     status = os::Solaris::cond_signal(_cond);
5592     assert(status == 0, "invariant");
5593   }
5594 }
5595 
5596 extern char** environ;
5597 
5598 // Run the specified command in a separate process. Return its exit value,
5599 // or -1 on failure (e.g. can't fork a new process).
5600 // Unlike system(), this function can be called from signal handler. It
5601 // doesn't block SIGINT et al.
5602 int os::fork_and_exec(char* cmd) {
5603   char * argv[4];
5604   argv[0] = (char *)"sh";
5605   argv[1] = (char *)"-c";
5606   argv[2] = cmd;
5607   argv[3] = NULL;
5608 
5609   // fork is async-safe, fork1 is not so can't use in signal handler
5610   pid_t pid;
5611   Thread* t = Thread::current_or_null_safe();
5612   if (t != NULL && t->is_inside_signal_handler()) {
5613     pid = fork();
5614   } else {
5615     pid = fork1();
5616   }
5617 
5618   if (pid < 0) {
5619     // fork failed
5620     warning("fork failed: %s", strerror(errno));
5621     return -1;
5622 
5623   } else if (pid == 0) {
5624     // child process
5625 
5626     // try to be consistent with system(), which uses "/usr/bin/sh" on Solaris
5627     execve("/usr/bin/sh", argv, environ);
5628 
5629     // execve failed
5630     _exit(-1);
5631 


< prev index next >