< prev index next >

src/hotspot/share/runtime/os.cpp

Print this page




 426 
 427 void os::init_before_ergo() {
 428   initialize_initial_active_processor_count();
 429   // We need to initialize large page support here because ergonomics takes some
 430   // decisions depending on large page support and the calculated large page size.
 431   large_page_init();
 432 
 433   // We need to adapt the configured number of stack protection pages given
 434   // in 4K pages to the actual os page size. We must do this before setting
 435   // up minimal stack sizes etc. in os::init_2().
 436   JavaThread::set_stack_red_zone_size     (align_up(StackRedPages      * 4 * K, vm_page_size()));
 437   JavaThread::set_stack_yellow_zone_size  (align_up(StackYellowPages   * 4 * K, vm_page_size()));
 438   JavaThread::set_stack_reserved_zone_size(align_up(StackReservedPages * 4 * K, vm_page_size()));
 439   JavaThread::set_stack_shadow_zone_size  (align_up(StackShadowPages   * 4 * K, vm_page_size()));
 440 
 441   // VM version initialization identifies some characteristics of the
 442   // platform that are used during ergonomic decisions.
 443   VM_Version::init_before_ergo();
 444 }
 445 
 446 void os::signal_init(TRAPS) {
 447   if (!ReduceSignalUsage) {
 448     // Setup JavaThread for processing signals
 449     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
 450     InstanceKlass* ik = InstanceKlass::cast(k);
 451     instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
 452 
 453     const char thread_name[] = "Signal Dispatcher";
 454     Handle string = java_lang_String::create_from_str(thread_name, CHECK);
 455 
 456     // Initialize thread_oop to put it into the system threadGroup
 457     Handle thread_group (THREAD, Universe::system_thread_group());
 458     JavaValue result(T_VOID);
 459     JavaCalls::call_special(&result, thread_oop,
 460                            ik,
 461                            vmSymbols::object_initializer_name(),
 462                            vmSymbols::threadgroup_string_void_signature(),
 463                            thread_group,
 464                            string,
 465                            CHECK);
 466 
 467     Klass* group = SystemDictionary::ThreadGroup_klass();
 468     JavaCalls::call_special(&result,
 469                             thread_group,
 470                             group,
 471                             vmSymbols::add_method_name(),
 472                             vmSymbols::thread_void_signature(),
 473                             thread_oop,         // ARG 1
 474                             CHECK);
 475 
 476     os::signal_init_pd();
 477 
 478     { MutexLocker mu(Threads_lock);
 479       JavaThread* signal_thread = new JavaThread(&signal_thread_entry);
 480 
 481       // At this point it may be possible that no osthread was created for the
 482       // JavaThread due to lack of memory. We would have to throw an exception
 483       // in that case. However, since this must work and we do not allow
 484       // exceptions anyway, check and abort if this fails.
 485       if (signal_thread == NULL || signal_thread->osthread() == NULL) {
 486         vm_exit_during_initialization("java.lang.OutOfMemoryError",
 487                                       os::native_thread_creation_failed_msg());
 488       }
 489 
 490       java_lang_Thread::set_thread(thread_oop(), signal_thread);
 491       java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
 492       java_lang_Thread::set_daemon(thread_oop());
 493 
 494       signal_thread->set_threadObj(thread_oop());
 495       Threads::add(signal_thread);
 496       Thread::start(signal_thread);




 426 
 427 void os::init_before_ergo() {
 428   initialize_initial_active_processor_count();
 429   // We need to initialize large page support here because ergonomics takes some
 430   // decisions depending on large page support and the calculated large page size.
 431   large_page_init();
 432 
 433   // We need to adapt the configured number of stack protection pages given
 434   // in 4K pages to the actual os page size. We must do this before setting
 435   // up minimal stack sizes etc. in os::init_2().
 436   JavaThread::set_stack_red_zone_size     (align_up(StackRedPages      * 4 * K, vm_page_size()));
 437   JavaThread::set_stack_yellow_zone_size  (align_up(StackYellowPages   * 4 * K, vm_page_size()));
 438   JavaThread::set_stack_reserved_zone_size(align_up(StackReservedPages * 4 * K, vm_page_size()));
 439   JavaThread::set_stack_shadow_zone_size  (align_up(StackShadowPages   * 4 * K, vm_page_size()));
 440 
 441   // VM version initialization identifies some characteristics of the
 442   // platform that are used during ergonomic decisions.
 443   VM_Version::init_before_ergo();
 444 }
 445 
 446 void os::initialize_jdk_signal_support(TRAPS) {
 447   if (!ReduceSignalUsage) {
 448     // Setup JavaThread for processing signals
 449     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
 450     InstanceKlass* ik = InstanceKlass::cast(k);
 451     instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
 452 
 453     const char thread_name[] = "Signal Dispatcher";
 454     Handle string = java_lang_String::create_from_str(thread_name, CHECK);
 455 
 456     // Initialize thread_oop to put it into the system threadGroup
 457     Handle thread_group (THREAD, Universe::system_thread_group());
 458     JavaValue result(T_VOID);
 459     JavaCalls::call_special(&result, thread_oop,
 460                            ik,
 461                            vmSymbols::object_initializer_name(),
 462                            vmSymbols::threadgroup_string_void_signature(),
 463                            thread_group,
 464                            string,
 465                            CHECK);
 466 
 467     Klass* group = SystemDictionary::ThreadGroup_klass();
 468     JavaCalls::call_special(&result,
 469                             thread_group,
 470                             group,
 471                             vmSymbols::add_method_name(),
 472                             vmSymbols::thread_void_signature(),
 473                             thread_oop,         // ARG 1
 474                             CHECK);


 475 
 476     { MutexLocker mu(Threads_lock);
 477       JavaThread* signal_thread = new JavaThread(&signal_thread_entry);
 478 
 479       // At this point it may be possible that no osthread was created for the
 480       // JavaThread due to lack of memory. We would have to throw an exception
 481       // in that case. However, since this must work and we do not allow
 482       // exceptions anyway, check and abort if this fails.
 483       if (signal_thread == NULL || signal_thread->osthread() == NULL) {
 484         vm_exit_during_initialization("java.lang.OutOfMemoryError",
 485                                       os::native_thread_creation_failed_msg());
 486       }
 487 
 488       java_lang_Thread::set_thread(thread_oop(), signal_thread);
 489       java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
 490       java_lang_Thread::set_daemon(thread_oop());
 491 
 492       signal_thread->set_threadObj(thread_oop());
 493       Threads::add(signal_thread);
 494       Thread::start(signal_thread);


< prev index next >