119 // global variables
120 julong os::Bsd::_physical_memory = 0;
121
122 #ifdef __APPLE__
123 mach_timebase_info_data_t os::Bsd::_timebase_info = {0, 0};
124 volatile uint64_t os::Bsd::_max_abstime = 0;
125 #else
126 int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL;
127 #endif
128 pthread_t os::Bsd::_main_thread;
129 int os::Bsd::_page_size = -1;
130
131 static jlong initial_time_count=0;
132
133 static int clock_tics_per_sec = 100;
134
135 // For diagnostics to print a message once. see run_periodic_checks
136 static sigset_t check_signal_done;
137 static bool check_signals = true;
138
139 static pid_t _initial_pid = 0;
140
141 // Signal number used to suspend/resume a thread
142
143 // do not use any signal number less than SIGSEGV, see 4355769
144 static int SR_signum = SIGUSR2;
145 sigset_t SR_sigset;
146
147
148 ////////////////////////////////////////////////////////////////////////////////
149 // utility functions
150
151 static int SR_initialize();
152
153 julong os::available_memory() {
154 return Bsd::available_memory();
155 }
156
157 // available here means free
158 julong os::Bsd::available_memory() {
159 uint64_t available = physical_memory() >> 2;
160 #ifdef __APPLE__
1107 retval = (pid_t) syscall(SYS__lwp_self);
1108 #endif
1109 #endif
1110 #endif
1111 #endif
1112
1113 if (retval == -1) {
1114 return getpid();
1115 }
1116 }
1117
1118 intx os::current_thread_id() {
1119 #ifdef __APPLE__
1120 return (intx)::pthread_mach_thread_np(::pthread_self());
1121 #else
1122 return (intx)::pthread_self();
1123 #endif
1124 }
1125
1126 int os::current_process_id() {
1127
1128 // Under the old bsd thread library, bsd gives each thread
1129 // its own process id. Because of this each thread will return
1130 // a different pid if this method were to return the result
1131 // of getpid(2). Bsd provides no api that returns the pid
1132 // of the launcher thread for the vm. This implementation
1133 // returns a unique pid, the pid of the launcher thread
1134 // that starts the vm 'process'.
1135
1136 // Under the NPTL, getpid() returns the same pid as the
1137 // launcher thread rather than a unique pid per thread.
1138 // Use gettid() if you want the old pre NPTL behaviour.
1139
1140 // if you are looking for the result of a call to getpid() that
1141 // returns a unique pid for the calling thread, then look at the
1142 // OSThread::thread_id() method in osThread_bsd.hpp file
1143
1144 return (int)(_initial_pid ? _initial_pid : getpid());
1145 }
1146
1147 // DLL functions
1148
1149 const char* os::dll_file_extension() { return JNI_LIB_SUFFIX; }
1150
1151 // This must be hard coded because it's the system's temporary
1152 // directory not the java application's temp directory, ala java.io.tmpdir.
1153 #ifdef __APPLE__
1154 // macosx has a secure per-user temporary directory
1155 char temp_path_storage[PATH_MAX];
1156 const char* os::get_temp_directory() {
1157 static char *temp_path = NULL;
1158 if (temp_path == NULL) {
1159 int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
1160 if (pathSize == 0 || pathSize > PATH_MAX) {
1161 strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage));
1162 }
1163 temp_path = temp_path_storage;
1164 }
3069 tty->cr();
3070 tty->print(" found:");
3071 os::Posix::print_sa_flags(tty, act.sa_flags);
3072 tty->cr();
3073 // No need to check this sig any longer
3074 sigaddset(&check_signal_done, sig);
3075 }
3076
3077 // Dump all the signal
3078 if (sigismember(&check_signal_done, sig)) {
3079 print_signal_handlers(tty, buf, O_BUFLEN);
3080 }
3081 }
3082
3083 extern void report_error(char* file_name, int line_no, char* title,
3084 char* format, ...);
3085
3086 // this is called _before_ the most of global arguments have been parsed
3087 void os::init(void) {
3088 char dummy; // used to get a guess on initial stack address
3089
3090 // With BsdThreads the JavaMain thread pid (primordial thread)
3091 // is different than the pid of the java launcher thread.
3092 // So, on Bsd, the launcher thread pid is passed to the VM
3093 // via the sun.java.launcher.pid property.
3094 // Use this property instead of getpid() if it was correctly passed.
3095 // See bug 6351349.
3096 pid_t java_launcher_pid = (pid_t) Arguments::sun_java_launcher_pid();
3097
3098 _initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid();
3099
3100 clock_tics_per_sec = CLK_TCK;
3101
3102 init_random(1234567);
3103
3104 Bsd::set_page_size(getpagesize());
3105 if (Bsd::page_size() == -1) {
3106 fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
3107 }
3108 init_page_sizes((size_t) Bsd::page_size());
3109
3110 Bsd::initialize_system_info();
3111
3112 // _main_thread points to the thread that created/loaded the JVM.
3113 Bsd::_main_thread = pthread_self();
3114
3115 Bsd::clock_init();
3116 initial_time_count = javaTimeNanos();
3117
3118 os::Posix::init();
|
119 // global variables
120 julong os::Bsd::_physical_memory = 0;
121
122 #ifdef __APPLE__
123 mach_timebase_info_data_t os::Bsd::_timebase_info = {0, 0};
124 volatile uint64_t os::Bsd::_max_abstime = 0;
125 #else
126 int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL;
127 #endif
128 pthread_t os::Bsd::_main_thread;
129 int os::Bsd::_page_size = -1;
130
131 static jlong initial_time_count=0;
132
133 static int clock_tics_per_sec = 100;
134
135 // For diagnostics to print a message once. see run_periodic_checks
136 static sigset_t check_signal_done;
137 static bool check_signals = true;
138
139 // Signal number used to suspend/resume a thread
140
141 // do not use any signal number less than SIGSEGV, see 4355769
142 static int SR_signum = SIGUSR2;
143 sigset_t SR_sigset;
144
145
146 ////////////////////////////////////////////////////////////////////////////////
147 // utility functions
148
149 static int SR_initialize();
150
151 julong os::available_memory() {
152 return Bsd::available_memory();
153 }
154
155 // available here means free
156 julong os::Bsd::available_memory() {
157 uint64_t available = physical_memory() >> 2;
158 #ifdef __APPLE__
1105 retval = (pid_t) syscall(SYS__lwp_self);
1106 #endif
1107 #endif
1108 #endif
1109 #endif
1110
1111 if (retval == -1) {
1112 return getpid();
1113 }
1114 }
1115
1116 intx os::current_thread_id() {
1117 #ifdef __APPLE__
1118 return (intx)::pthread_mach_thread_np(::pthread_self());
1119 #else
1120 return (intx)::pthread_self();
1121 #endif
1122 }
1123
1124 int os::current_process_id() {
1125 return (int)(getpid());
1126 }
1127
1128 // DLL functions
1129
1130 const char* os::dll_file_extension() { return JNI_LIB_SUFFIX; }
1131
1132 // This must be hard coded because it's the system's temporary
1133 // directory not the java application's temp directory, ala java.io.tmpdir.
1134 #ifdef __APPLE__
1135 // macosx has a secure per-user temporary directory
1136 char temp_path_storage[PATH_MAX];
1137 const char* os::get_temp_directory() {
1138 static char *temp_path = NULL;
1139 if (temp_path == NULL) {
1140 int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
1141 if (pathSize == 0 || pathSize > PATH_MAX) {
1142 strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage));
1143 }
1144 temp_path = temp_path_storage;
1145 }
3050 tty->cr();
3051 tty->print(" found:");
3052 os::Posix::print_sa_flags(tty, act.sa_flags);
3053 tty->cr();
3054 // No need to check this sig any longer
3055 sigaddset(&check_signal_done, sig);
3056 }
3057
3058 // Dump all the signal
3059 if (sigismember(&check_signal_done, sig)) {
3060 print_signal_handlers(tty, buf, O_BUFLEN);
3061 }
3062 }
3063
3064 extern void report_error(char* file_name, int line_no, char* title,
3065 char* format, ...);
3066
3067 // this is called _before_ the most of global arguments have been parsed
3068 void os::init(void) {
3069 char dummy; // used to get a guess on initial stack address
3070
3071 clock_tics_per_sec = CLK_TCK;
3072
3073 init_random(1234567);
3074
3075 Bsd::set_page_size(getpagesize());
3076 if (Bsd::page_size() == -1) {
3077 fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
3078 }
3079 init_page_sizes((size_t) Bsd::page_size());
3080
3081 Bsd::initialize_system_info();
3082
3083 // _main_thread points to the thread that created/loaded the JVM.
3084 Bsd::_main_thread = pthread_self();
3085
3086 Bsd::clock_init();
3087 initial_time_count = javaTimeNanos();
3088
3089 os::Posix::init();
|