427 // applications that host the JVM directly may do so. Some platforms
428 // need special-case handling of the primordial thread if it attaches
429 // to the VM.
430 static bool is_primordial_thread(void)
431 #if defined(_WINDOWS) || defined(BSD)
432 // No way to identify the primordial thread.
433 { return false; }
434 #else
435 ;
436 #endif
437
438 static bool create_attached_thread(JavaThread* thread);
439 static void pd_start_thread(Thread* thread);
440 static void start_thread(Thread* thread);
441
442 // Returns true if successful.
443 static bool signal_thread(Thread* thread, int sig, const char* reason);
444
445 static void free_thread(OSThread* osthread);
446
447 // thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit
448 static intx current_thread_id();
449 static int current_process_id();
450
451 // Short standalone OS sleep routines suitable for slow path spin loop.
452 // Ignores safepoints/suspension/Thread.interrupt() (so keep it short).
453 // ms/ns = 0, will sleep for the least amount of time allowed by the OS.
454 // Maximum sleep time is just under 1 second.
455 static void naked_short_sleep(jlong ms);
456 static void naked_short_nanosleep(jlong ns);
457 // Longer standalone OS sleep routine - a convenience wrapper around
458 // multiple calls to naked_short_sleep. Only for use by non-JavaThreads.
459 static void naked_sleep(jlong millis);
460 // Never returns, use with CAUTION
461 static void infinite_sleep();
462 static void naked_yield () ;
463 static OSReturn set_priority(Thread* thread, ThreadPriority priority);
464 static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority);
465
466 static int pd_self_suspend_thread(Thread* thread);
467
754 static void init_random(unsigned int initval); // initialize random sequence
755
756 // Structured OS Exception support
757 static void os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandle& method, JavaCallArguments* args, Thread* thread);
758
759 // On Posix compatible OS it will simply check core dump limits while on Windows
760 // it will check if dump file can be created. Check or prepare a core dump to be
761 // taken at a later point in the same thread in os::abort(). Use the caller
762 // provided buffer as a scratch buffer. The status message which will be written
763 // into the error log either is file location or a short error message, depending
764 // on the checking result.
765 static void check_dump_limit(char* buffer, size_t bufferSize);
766
767 // Get the default path to the core file
768 // Returns the length of the string
769 static int get_core_path(char* buffer, size_t bufferSize);
770
771 // JVMTI & JVM monitoring and management support
772 // The thread_cpu_time() and current_thread_cpu_time() are only
773 // supported if is_thread_cpu_time_supported() returns true.
774 // They are not supported on Solaris T1.
775
776 // Thread CPU Time - return the fast estimate on a platform
777 // On Solaris - call gethrvtime (fast) - user time only
778 // On Linux - fast clock_gettime where available - user+sys
779 // - otherwise: very slow /proc fs - user+sys
780 // On Windows - GetThreadTimes - user+sys
781 static jlong current_thread_cpu_time();
782 static jlong thread_cpu_time(Thread* t);
783
784 // Thread CPU Time with user_sys_cpu_time parameter.
785 //
786 // If user_sys_cpu_time is true, user+sys time is returned.
787 // Otherwise, only user time is returned
788 static jlong current_thread_cpu_time(bool user_sys_cpu_time);
789 static jlong thread_cpu_time(Thread* t, bool user_sys_cpu_time);
790
791 // Return a bunch of info about the timers.
792 // Note that the returned info for these two functions may be different
793 // on some platforms
794 static void current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
795 static void thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
796
797 static bool is_thread_cpu_time_supported();
|
427 // applications that host the JVM directly may do so. Some platforms
428 // need special-case handling of the primordial thread if it attaches
429 // to the VM.
430 static bool is_primordial_thread(void)
431 #if defined(_WINDOWS) || defined(BSD)
432 // No way to identify the primordial thread.
433 { return false; }
434 #else
435 ;
436 #endif
437
438 static bool create_attached_thread(JavaThread* thread);
439 static void pd_start_thread(Thread* thread);
440 static void start_thread(Thread* thread);
441
442 // Returns true if successful.
443 static bool signal_thread(Thread* thread, int sig, const char* reason);
444
445 static void free_thread(OSThread* osthread);
446
447 // thread id on Linux/64bit is 64bit, on Windows it's 32bit
448 static intx current_thread_id();
449 static int current_process_id();
450
451 // Short standalone OS sleep routines suitable for slow path spin loop.
452 // Ignores safepoints/suspension/Thread.interrupt() (so keep it short).
453 // ms/ns = 0, will sleep for the least amount of time allowed by the OS.
454 // Maximum sleep time is just under 1 second.
455 static void naked_short_sleep(jlong ms);
456 static void naked_short_nanosleep(jlong ns);
457 // Longer standalone OS sleep routine - a convenience wrapper around
458 // multiple calls to naked_short_sleep. Only for use by non-JavaThreads.
459 static void naked_sleep(jlong millis);
460 // Never returns, use with CAUTION
461 static void infinite_sleep();
462 static void naked_yield () ;
463 static OSReturn set_priority(Thread* thread, ThreadPriority priority);
464 static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority);
465
466 static int pd_self_suspend_thread(Thread* thread);
467
754 static void init_random(unsigned int initval); // initialize random sequence
755
756 // Structured OS Exception support
757 static void os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandle& method, JavaCallArguments* args, Thread* thread);
758
759 // On Posix compatible OS it will simply check core dump limits while on Windows
760 // it will check if dump file can be created. Check or prepare a core dump to be
761 // taken at a later point in the same thread in os::abort(). Use the caller
762 // provided buffer as a scratch buffer. The status message which will be written
763 // into the error log either is file location or a short error message, depending
764 // on the checking result.
765 static void check_dump_limit(char* buffer, size_t bufferSize);
766
767 // Get the default path to the core file
768 // Returns the length of the string
769 static int get_core_path(char* buffer, size_t bufferSize);
770
771 // JVMTI & JVM monitoring and management support
772 // The thread_cpu_time() and current_thread_cpu_time() are only
773 // supported if is_thread_cpu_time_supported() returns true.
774
775 // Thread CPU Time - return the fast estimate on a platform
776 // On Linux - fast clock_gettime where available - user+sys
777 // - otherwise: very slow /proc fs - user+sys
778 // On Windows - GetThreadTimes - user+sys
779 static jlong current_thread_cpu_time();
780 static jlong thread_cpu_time(Thread* t);
781
782 // Thread CPU Time with user_sys_cpu_time parameter.
783 //
784 // If user_sys_cpu_time is true, user+sys time is returned.
785 // Otherwise, only user time is returned
786 static jlong current_thread_cpu_time(bool user_sys_cpu_time);
787 static jlong thread_cpu_time(Thread* t, bool user_sys_cpu_time);
788
789 // Return a bunch of info about the timers.
790 // Note that the returned info for these two functions may be different
791 // on some platforms
792 static void current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
793 static void thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
794
795 static bool is_thread_cpu_time_supported();
|