5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // os defines the interface to operating system; this includes traditional
26 // OS services (time, I/O) as well as other functionality with system-
27 // dependent code.
28
29 typedef void (*dll_func)(...);
30
31 class Thread;
32 class JavaThread;
33 class Event;
34 class DLL;
35 class FileHandle;
36 template<class E> class GrowableArray;
37
38 // %%%%% Moved ThreadState, START_FN, OSThread to new osThread.hpp. -- Rose
39
40 // Platform-independent error return values from OS functions
41 enum OSReturn {
42 OS_OK = 0, // Operation was successful
43 OS_ERR = -1, // Operation failed
44 OS_INTRPT = -2, // Operation was interrupted
569 // If user_sys_cpu_time is true, user+sys time is returned.
570 // Otherwise, only user time is returned
571 static jlong current_thread_cpu_time(bool user_sys_cpu_time);
572 static jlong thread_cpu_time(Thread* t, bool user_sys_cpu_time);
573
574 // Return a bunch of info about the timers.
575 // Note that the returned info for these two functions may be different
576 // on some platforms
577 static void current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
578 static void thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
579
580 static bool is_thread_cpu_time_supported();
581
582 // System loadavg support. Returns -1 if load average cannot be obtained.
583 static int loadavg(double loadavg[], int nelem);
584
585 // Hook for os specific jvm options that we don't want to abort on seeing
586 static bool obsolete_option(const JavaVMOption *option);
587
588 // Platform dependent stuff
589 #include "incls/_os_pd.hpp.incl"
590
591 // debugging support (mostly used by debug.cpp but also fatal error handler)
592 static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address
593
594 static bool dont_yield(); // when true, JVM_Yield() is nop
595 static void print_statistics();
596
597 // Thread priority helpers (implemented in OS-specific part)
598 static OSReturn set_native_priority(Thread* thread, int native_prio);
599 static OSReturn get_native_priority(const Thread* const thread, int* priority_ptr);
600 static int java_to_os_priority[MaxPriority + 1];
601 // Hint to the underlying OS that a task switch would not be good.
602 // Void return because it's a hint and can fail.
603 static void hint_no_preempt();
604
605 // Used at creation if requested by the diagnostic flag PauseAtStartup.
606 // Causes the VM to wait until an external stimulus has been applied
607 // (for Unix, that stimulus is a signal, for Windows, an external
608 // ResumeThread call)
609 static void pause();
612 static long _rand_seed; // seed for random number generator
613 static int _processor_count; // number of processors
614
615 static char* format_boot_path(const char* format_string,
616 const char* home,
617 int home_len,
618 char fileSep,
619 char pathSep);
620 static bool set_boot_path(char fileSep, char pathSep);
621 static char** split_path(const char* path, int* n);
622 };
623
624 // Note that "PAUSE" is almost always used with synchronization
625 // so arguably we should provide Atomic::SpinPause() instead
626 // of the global SpinPause() with C linkage.
627 // It'd also be eligible for inlining on many platforms.
628
629 extern "C" int SpinPause () ;
630 extern "C" int SafeFetch32 (int * adr, int errValue) ;
631 extern "C" intptr_t SafeFetchN (intptr_t * adr, intptr_t errValue) ;
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_OS_HPP
26 #define SHARE_VM_RUNTIME_OS_HPP
27
28 #include "jvmtifiles/jvmti.h"
29 #include "runtime/atomic.hpp"
30 #include "runtime/extendedPC.hpp"
31 #include "runtime/handles.hpp"
32 #include "utilities/top.hpp"
33 #ifdef TARGET_OS_FAMILY_linux
34 # include "jvm_linux.h"
35 #endif
36 #ifdef TARGET_OS_FAMILY_solaris
37 # include "jvm_solaris.h"
38 #endif
39 #ifdef TARGET_OS_FAMILY_windows
40 # include "jvm_windows.h"
41 #endif
42
43 // os defines the interface to operating system; this includes traditional
44 // OS services (time, I/O) as well as other functionality with system-
45 // dependent code.
46
47 typedef void (*dll_func)(...);
48
49 class Thread;
50 class JavaThread;
51 class Event;
52 class DLL;
53 class FileHandle;
54 template<class E> class GrowableArray;
55
56 // %%%%% Moved ThreadState, START_FN, OSThread to new osThread.hpp. -- Rose
57
58 // Platform-independent error return values from OS functions
59 enum OSReturn {
60 OS_OK = 0, // Operation was successful
61 OS_ERR = -1, // Operation failed
62 OS_INTRPT = -2, // Operation was interrupted
587 // If user_sys_cpu_time is true, user+sys time is returned.
588 // Otherwise, only user time is returned
589 static jlong current_thread_cpu_time(bool user_sys_cpu_time);
590 static jlong thread_cpu_time(Thread* t, bool user_sys_cpu_time);
591
592 // Return a bunch of info about the timers.
593 // Note that the returned info for these two functions may be different
594 // on some platforms
595 static void current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
596 static void thread_cpu_time_info(jvmtiTimerInfo *info_ptr);
597
598 static bool is_thread_cpu_time_supported();
599
600 // System loadavg support. Returns -1 if load average cannot be obtained.
601 static int loadavg(double loadavg[], int nelem);
602
603 // Hook for os specific jvm options that we don't want to abort on seeing
604 static bool obsolete_option(const JavaVMOption *option);
605
606 // Platform dependent stuff
607 #ifdef TARGET_OS_FAMILY_linux
608 # include "os_linux.hpp"
609 #endif
610 #ifdef TARGET_OS_FAMILY_solaris
611 # include "os_solaris.hpp"
612 #endif
613 #ifdef TARGET_OS_FAMILY_windows
614 # include "os_windows.hpp"
615 #endif
616 #ifdef TARGET_OS_ARCH_linux_x86
617 # include "os_linux_x86.hpp"
618 #endif
619 #ifdef TARGET_OS_ARCH_linux_sparc
620 # include "os_linux_sparc.hpp"
621 #endif
622 #ifdef TARGET_OS_ARCH_linux_zero
623 # include "os_linux_zero.hpp"
624 #endif
625 #ifdef TARGET_OS_ARCH_solaris_x86
626 # include "os_solaris_x86.hpp"
627 #endif
628 #ifdef TARGET_OS_ARCH_solaris_sparc
629 # include "os_solaris_sparc.hpp"
630 #endif
631 #ifdef TARGET_OS_ARCH_windows_x86
632 # include "os_windows_x86.hpp"
633 #endif
634
635
636 // debugging support (mostly used by debug.cpp but also fatal error handler)
637 static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address
638
639 static bool dont_yield(); // when true, JVM_Yield() is nop
640 static void print_statistics();
641
642 // Thread priority helpers (implemented in OS-specific part)
643 static OSReturn set_native_priority(Thread* thread, int native_prio);
644 static OSReturn get_native_priority(const Thread* const thread, int* priority_ptr);
645 static int java_to_os_priority[MaxPriority + 1];
646 // Hint to the underlying OS that a task switch would not be good.
647 // Void return because it's a hint and can fail.
648 static void hint_no_preempt();
649
650 // Used at creation if requested by the diagnostic flag PauseAtStartup.
651 // Causes the VM to wait until an external stimulus has been applied
652 // (for Unix, that stimulus is a signal, for Windows, an external
653 // ResumeThread call)
654 static void pause();
657 static long _rand_seed; // seed for random number generator
658 static int _processor_count; // number of processors
659
660 static char* format_boot_path(const char* format_string,
661 const char* home,
662 int home_len,
663 char fileSep,
664 char pathSep);
665 static bool set_boot_path(char fileSep, char pathSep);
666 static char** split_path(const char* path, int* n);
667 };
668
669 // Note that "PAUSE" is almost always used with synchronization
670 // so arguably we should provide Atomic::SpinPause() instead
671 // of the global SpinPause() with C linkage.
672 // It'd also be eligible for inlining on many platforms.
673
674 extern "C" int SpinPause () ;
675 extern "C" int SafeFetch32 (int * adr, int errValue) ;
676 extern "C" intptr_t SafeFetchN (intptr_t * adr, intptr_t errValue) ;
677
678 #endif // SHARE_VM_RUNTIME_OS_HPP
|