< prev index next >

src/os/solaris/vm/os_solaris.cpp

Print this page




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



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


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




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


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


< prev index next >