src/os/linux/vm/os_linux.hpp

Fri, 06 Jul 2018 18:50:13 +0000

author
poonam
date
Fri, 06 Jul 2018 18:50:13 +0000
changeset 9413
5aa3d728164a
parent 9182
0f31f18d2241
child 9417
65409bcab2ad
permissions
-rw-r--r--

8146115: Improve docker container detection and resource configuration usage
Reviewed-by: bobv, dbuck

duke@435 1 /*
simonis@4675 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef OS_LINUX_VM_OS_LINUX_HPP
stefank@2314 26 #define OS_LINUX_VM_OS_LINUX_HPP
stefank@2314 27
duke@435 28 // Linux_OS defines the interface to Linux operating systems
duke@435 29
duke@435 30 /* pthread_getattr_np comes with LinuxThreads-0.9-7 on RedHat 7.1 */
duke@435 31 typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
duke@435 32
goetz@6486 33 // Information about the protection of the page at address '0' on this os.
goetz@6486 34 static bool zero_page_read_protected() { return true; }
goetz@6486 35
duke@435 36 class Linux {
duke@435 37 friend class os;
poonam@9413 38 friend class OSContainer;
stefank@5578 39 friend class TestReserveMemorySpecial;
duke@435 40
duke@435 41 // For signal-chaining
duke@435 42 #define MAXSIGNUM 32
duke@435 43 static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
duke@435 44 static unsigned int sigs; // mask of signals that have
duke@435 45 // preinstalled signal handlers
duke@435 46 static bool libjsig_is_loaded; // libjsig that interposes sigaction(),
duke@435 47 // __sigaction(), signal() is loaded
duke@435 48 static struct sigaction *(*get_signal_action)(int);
duke@435 49 static struct sigaction *get_preinstalled_handler(int);
duke@435 50 static void save_preinstalled_handler(int, struct sigaction&);
duke@435 51
duke@435 52 static void check_signal_handler(int sig);
duke@435 53
duke@435 54 // For signal flags diagnostics
duke@435 55 static int sigflags[MAXSIGNUM];
duke@435 56
duke@435 57 static int (*_clock_gettime)(clockid_t, struct timespec *);
duke@435 58 static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
duke@435 59
duke@435 60 static address _initial_thread_stack_bottom;
duke@435 61 static uintptr_t _initial_thread_stack_size;
duke@435 62
xlu@634 63 static const char *_glibc_version;
xlu@634 64 static const char *_libpthread_version;
duke@435 65
duke@435 66 static bool _is_floating_stack;
duke@435 67 static bool _is_NPTL;
duke@435 68 static bool _supports_fast_thread_cpu_time;
duke@435 69
iveresov@576 70 static GrowableArray<int>* _cpu_to_node;
gromero@8776 71 static GrowableArray<int>* _nindex_to_node;
iveresov@576 72
duke@435 73 protected:
duke@435 74
duke@435 75 static julong _physical_memory;
duke@435 76 static pthread_t _main_thread;
duke@435 77 static Mutex* _createThread_lock;
duke@435 78 static int _page_size;
vladidan@4996 79 static const int _vm_default_page_size;
duke@435 80
duke@435 81 static julong available_memory();
duke@435 82 static julong physical_memory() { return _physical_memory; }
poonam@9413 83 static void set_physical_memory(julong phys_mem) { _physical_memory = phys_mem; }
poonam@9413 84 static int active_processor_count();
poonam@9413 85
duke@435 86 static void initialize_system_info();
duke@435 87
dcubed@5255 88 static int commit_memory_impl(char* addr, size_t bytes, bool exec);
dcubed@5255 89 static int commit_memory_impl(char* addr, size_t bytes,
dcubed@5255 90 size_t alignment_hint, bool exec);
dcubed@5255 91
xlu@634 92 static void set_glibc_version(const char *s) { _glibc_version = s; }
xlu@634 93 static void set_libpthread_version(const char *s) { _libpthread_version = s; }
duke@435 94
duke@435 95 static bool supports_variable_stack_size();
duke@435 96
duke@435 97 static void set_is_NPTL() { _is_NPTL = true; }
duke@435 98 static void set_is_LinuxThreads() { _is_NPTL = false; }
duke@435 99 static void set_is_floating_stack() { _is_floating_stack = true; }
duke@435 100
iveresov@576 101 static void rebuild_cpu_to_node_map();
gromero@8776 102 static void rebuild_nindex_to_node_map();
iveresov@576 103 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
gromero@8776 104 static GrowableArray<int>* nindex_to_node() { return _nindex_to_node; }
iveresov@2818 105
stefank@5578 106 static size_t find_large_page_size();
stefank@5578 107 static size_t setup_large_page_size();
stefank@5578 108
stefank@5578 109 static bool setup_large_page_type(size_t page_size);
stefank@5578 110 static bool transparent_huge_pages_sanity_check(bool warn, size_t pages_size);
iveresov@2818 111 static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
iveresov@2818 112
stefank@5578 113 static char* reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec);
stefank@5578 114 static char* reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec);
stefank@5578 115 static char* reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec);
stefank@5578 116 static char* reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec);
stefank@5578 117
zgu@7074 118 static bool release_memory_special_impl(char* base, size_t bytes);
stefank@5578 119 static bool release_memory_special_shm(char* base, size_t bytes);
stefank@5578 120 static bool release_memory_special_huge_tlbfs(char* base, size_t bytes);
stefank@5578 121
nloodin@3783 122 static void print_full_memory_info(outputStream* st);
poonam@9413 123 static void print_container_info(outputStream* st);
nloodin@3783 124 static void print_distro_info(outputStream* st);
nloodin@3783 125 static void print_libversion_info(outputStream* st);
nloodin@3783 126
duke@435 127 public:
iklam@4710 128 static bool _stack_is_executable;
iklam@4812 129 static void *dlopen_helper(const char *name, char *ebuf, int ebuflen);
iklam@4812 130 static void *dll_load_in_vmthread(const char *name, char *ebuf, int ebuflen);
iklam@4710 131
duke@435 132 static void init_thread_fpu_state();
duke@435 133 static int get_fpu_control_word();
duke@435 134 static void set_fpu_control_word(int fpu_control);
duke@435 135 static pthread_t main_thread(void) { return _main_thread; }
duke@435 136 // returns kernel thread id (similar to LWP id on Solaris), which can be
duke@435 137 // used to access /proc
duke@435 138 static pid_t gettid();
duke@435 139 static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }
duke@435 140 static Mutex* createThread_lock(void) { return _createThread_lock; }
duke@435 141 static void hotspot_sigmask(Thread* thread);
duke@435 142
duke@435 143 static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; }
duke@435 144 static uintptr_t initial_thread_stack_size(void) { return _initial_thread_stack_size; }
duke@435 145 static bool is_initial_thread(void);
duke@435 146
duke@435 147 static int page_size(void) { return _page_size; }
duke@435 148 static void set_page_size(int val) { _page_size = val; }
duke@435 149
vladidan@4996 150 static int vm_default_page_size(void) { return _vm_default_page_size; }
vladidan@4996 151
duke@435 152 static address ucontext_get_pc(ucontext_t* uc);
duke@435 153 static intptr_t* ucontext_get_sp(ucontext_t* uc);
duke@435 154 static intptr_t* ucontext_get_fp(ucontext_t* uc);
duke@435 155
duke@435 156 // For Analyzer Forte AsyncGetCallTrace profiling support:
duke@435 157 //
duke@435 158 // This interface should be declared in os_linux_i486.hpp, but
duke@435 159 // that file provides extensions to the os class and not the
duke@435 160 // Linux class.
duke@435 161 static ExtendedPC fetch_frame_from_ucontext(Thread* thread, ucontext_t* uc,
duke@435 162 intptr_t** ret_sp, intptr_t** ret_fp);
duke@435 163
duke@435 164 // This boolean allows users to forward their own non-matching signals
duke@435 165 // to JVM_handle_linux_signal, harmlessly.
duke@435 166 static bool signal_handlers_are_installed;
duke@435 167
duke@435 168 static int get_our_sigflags(int);
duke@435 169 static void set_our_sigflags(int, int);
duke@435 170 static void signal_sets_init();
duke@435 171 static void install_signal_handlers();
duke@435 172 static void set_signal_handler(int, bool);
duke@435 173 static bool is_sig_ignored(int sig);
duke@435 174
duke@435 175 static sigset_t* unblocked_signals();
duke@435 176 static sigset_t* vm_signals();
duke@435 177 static sigset_t* allowdebug_blocked_signals();
duke@435 178
duke@435 179 // For signal-chaining
duke@435 180 static struct sigaction *get_chained_signal_action(int sig);
duke@435 181 static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
duke@435 182
duke@435 183 // GNU libc and libpthread version strings
xlu@634 184 static const char *glibc_version() { return _glibc_version; }
xlu@634 185 static const char *libpthread_version() { return _libpthread_version; }
duke@435 186
duke@435 187 // NPTL or LinuxThreads?
duke@435 188 static bool is_LinuxThreads() { return !_is_NPTL; }
duke@435 189 static bool is_NPTL() { return _is_NPTL; }
duke@435 190
duke@435 191 // NPTL is always floating stack. LinuxThreads could be using floating
duke@435 192 // stack or fixed stack.
duke@435 193 static bool is_floating_stack() { return _is_floating_stack; }
duke@435 194
duke@435 195 static void libpthread_init();
iveresov@897 196 static bool libnuma_init();
iveresov@1198 197 static void* libnuma_dlsym(void* handle, const char* name);
zgu@8878 198 // libnuma v2 (libnuma_1.2) symbols
zgu@8878 199 static void* libnuma_v2_dlsym(void* handle, const char* name);
duke@435 200 // Minimum stack size a thread can be created with (allowing
duke@435 201 // the VM to completely create the thread and enter user code)
duke@435 202 static size_t min_stack_allowed;
duke@435 203
duke@435 204 // Return default stack size or guard size for the specified thread type
duke@435 205 static size_t default_stack_size(os::ThreadType thr_type);
duke@435 206 static size_t default_guard_size(os::ThreadType thr_type);
duke@435 207
duke@435 208 static void capture_initial_stack(size_t max_size);
duke@435 209
duke@435 210 // Stack overflow handling
duke@435 211 static bool manually_expand_stack(JavaThread * t, address addr);
duke@435 212 static int max_register_window_saves_before_flushing();
duke@435 213
duke@435 214 // Real-time clock functions
duke@435 215 static void clock_init(void);
duke@435 216
duke@435 217 // fast POSIX clocks support
duke@435 218 static void fast_thread_clock_init(void);
duke@435 219
johnc@4017 220 static inline bool supports_monotonic_clock() {
duke@435 221 return _clock_gettime != NULL;
duke@435 222 }
duke@435 223
duke@435 224 static int clock_gettime(clockid_t clock_id, struct timespec *tp) {
duke@435 225 return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
duke@435 226 }
duke@435 227
duke@435 228 static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
duke@435 229 return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
duke@435 230 }
duke@435 231
duke@435 232 static bool supports_fast_thread_cpu_time() {
duke@435 233 return _supports_fast_thread_cpu_time;
duke@435 234 }
duke@435 235
duke@435 236 static jlong fast_thread_cpu_time(clockid_t clockid);
duke@435 237
dholmes@5679 238 // pthread_cond clock suppport
dholmes@5679 239 private:
dholmes@5679 240 static pthread_condattr_t _condattr[1];
dholmes@5679 241
dholmes@5679 242 public:
dholmes@5679 243 static pthread_condattr_t* condAttr() { return _condattr; }
dholmes@5679 244
duke@435 245 // Stack repair handling
duke@435 246
duke@435 247 // none present
duke@435 248
duke@435 249 // LinuxThreads work-around for 6292965
duke@435 250 static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
duke@435 251
iveresov@576 252 private:
iveresov@576 253 typedef int (*sched_getcpu_func_t)(void);
iveresov@576 254 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
iveresov@576 255 typedef int (*numa_max_node_func_t)(void);
gromero@8776 256 typedef int (*numa_num_configured_nodes_func_t)(void);
iveresov@576 257 typedef int (*numa_available_func_t)(void);
iveresov@576 258 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
iveresov@897 259 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
zgu@8878 260 typedef void (*numa_interleave_memory_v2_func_t)(void *start, size_t size, struct bitmask* mask);
zgu@8878 261
mgerdin@5644 262 typedef void (*numa_set_bind_policy_func_t)(int policy);
gromero@8776 263 typedef int (*numa_bitmask_isbitset_func_t)(struct bitmask *bmp, unsigned int n);
gromero@8776 264 typedef int (*numa_distance_func_t)(int node1, int node2);
iveresov@576 265
iveresov@576 266 static sched_getcpu_func_t _sched_getcpu;
iveresov@576 267 static numa_node_to_cpus_func_t _numa_node_to_cpus;
iveresov@576 268 static numa_max_node_func_t _numa_max_node;
gromero@8776 269 static numa_num_configured_nodes_func_t _numa_num_configured_nodes;
iveresov@576 270 static numa_available_func_t _numa_available;
iveresov@576 271 static numa_tonode_memory_func_t _numa_tonode_memory;
iveresov@897 272 static numa_interleave_memory_func_t _numa_interleave_memory;
zgu@8878 273 static numa_interleave_memory_v2_func_t _numa_interleave_memory_v2;
mgerdin@5644 274 static numa_set_bind_policy_func_t _numa_set_bind_policy;
gromero@8776 275 static numa_bitmask_isbitset_func_t _numa_bitmask_isbitset;
gromero@8776 276 static numa_distance_func_t _numa_distance;
iveresov@897 277 static unsigned long* _numa_all_nodes;
gromero@8776 278 static struct bitmask* _numa_all_nodes_ptr;
gromero@8776 279 static struct bitmask* _numa_nodes_ptr;
iveresov@576 280
iveresov@576 281 static void set_sched_getcpu(sched_getcpu_func_t func) { _sched_getcpu = func; }
iveresov@576 282 static void set_numa_node_to_cpus(numa_node_to_cpus_func_t func) { _numa_node_to_cpus = func; }
iveresov@576 283 static void set_numa_max_node(numa_max_node_func_t func) { _numa_max_node = func; }
gromero@8776 284 static void set_numa_num_configured_nodes(numa_num_configured_nodes_func_t func) { _numa_num_configured_nodes = func; }
iveresov@576 285 static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
iveresov@576 286 static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
iveresov@897 287 static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
zgu@8878 288 static void set_numa_interleave_memory_v2(numa_interleave_memory_v2_func_t func) { _numa_interleave_memory_v2 = func; }
mgerdin@5644 289 static void set_numa_set_bind_policy(numa_set_bind_policy_func_t func) { _numa_set_bind_policy = func; }
gromero@8776 290 static void set_numa_bitmask_isbitset(numa_bitmask_isbitset_func_t func) { _numa_bitmask_isbitset = func; }
gromero@8776 291 static void set_numa_distance(numa_distance_func_t func) { _numa_distance = func; }
iveresov@897 292 static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
gromero@9182 293 static void set_numa_all_nodes_ptr(struct bitmask **ptr) { _numa_all_nodes_ptr = (ptr == NULL ? NULL : *ptr); }
gromero@9182 294 static void set_numa_nodes_ptr(struct bitmask **ptr) { _numa_nodes_ptr = (ptr == NULL ? NULL : *ptr); }
iveresov@3024 295 static int sched_getcpu_syscall(void);
iveresov@576 296 public:
iveresov@576 297 static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
iveresov@576 298 static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
iveresov@576 299 return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
iveresov@576 300 }
iveresov@576 301 static int numa_max_node() { return _numa_max_node != NULL ? _numa_max_node() : -1; }
gromero@8776 302 static int numa_num_configured_nodes() {
gromero@8776 303 return _numa_num_configured_nodes != NULL ? _numa_num_configured_nodes() : -1;
gromero@8776 304 }
iveresov@576 305 static int numa_available() { return _numa_available != NULL ? _numa_available() : -1; }
iveresov@576 306 static int numa_tonode_memory(void *start, size_t size, int node) {
iveresov@576 307 return _numa_tonode_memory != NULL ? _numa_tonode_memory(start, size, node) : -1;
iveresov@576 308 }
iveresov@897 309 static void numa_interleave_memory(void *start, size_t size) {
zgu@8878 310 // Use v2 api if available
zgu@8878 311 if (_numa_interleave_memory_v2 != NULL && _numa_all_nodes_ptr != NULL) {
zgu@8878 312 _numa_interleave_memory_v2(start, size, _numa_all_nodes_ptr);
zgu@8878 313 } else if (_numa_interleave_memory != NULL && _numa_all_nodes != NULL) {
iveresov@897 314 _numa_interleave_memory(start, size, _numa_all_nodes);
iveresov@897 315 }
iveresov@897 316 }
mgerdin@5644 317 static void numa_set_bind_policy(int policy) {
mgerdin@5644 318 if (_numa_set_bind_policy != NULL) {
mgerdin@5644 319 _numa_set_bind_policy(policy);
mgerdin@5644 320 }
mgerdin@5644 321 }
gromero@8776 322 static int numa_distance(int node1, int node2) {
gromero@8776 323 return _numa_distance != NULL ? _numa_distance(node1, node2) : -1;
gromero@8776 324 }
iveresov@576 325 static int get_node_by_cpu(int cpu_id);
gromero@8776 326 static int get_existing_num_nodes();
gromero@8776 327 // Check if numa node is configured (non-zero memory node).
gromero@8776 328 static bool isnode_in_configured_nodes(unsigned int n) {
gromero@8776 329 if (_numa_bitmask_isbitset != NULL && _numa_all_nodes_ptr != NULL) {
gromero@8776 330 return _numa_bitmask_isbitset(_numa_all_nodes_ptr, n);
gromero@8776 331 } else
gromero@8776 332 return 0;
gromero@8776 333 }
gromero@8776 334 // Check if numa node exists in the system (including zero memory nodes).
gromero@8776 335 static bool isnode_in_existing_nodes(unsigned int n) {
gromero@8776 336 if (_numa_bitmask_isbitset != NULL && _numa_nodes_ptr != NULL) {
gromero@8776 337 return _numa_bitmask_isbitset(_numa_nodes_ptr, n);
gromero@9182 338 } else if (_numa_bitmask_isbitset != NULL && _numa_all_nodes_ptr != NULL) {
gromero@9182 339 // Not all libnuma API v2 implement numa_nodes_ptr, so it's not possible
gromero@9182 340 // to trust the API version for checking its absence. On the other hand,
gromero@9182 341 // numa_nodes_ptr found in libnuma 2.0.9 and above is the only way to get
gromero@9182 342 // a complete view of all numa nodes in the system, hence numa_nodes_ptr
gromero@9182 343 // is used to handle CPU and nodes on architectures (like PowerPC) where
gromero@9182 344 // there can exist nodes with CPUs but no memory or vice-versa and the
gromero@9182 345 // nodes may be non-contiguous. For most of the architectures, like
gromero@9182 346 // x86_64, numa_node_ptr presents the same node set as found in
gromero@9182 347 // numa_all_nodes_ptr so it's possible to use numa_all_nodes_ptr as a
gromero@9182 348 // substitute.
gromero@9182 349 return _numa_bitmask_isbitset(_numa_all_nodes_ptr, n);
gromero@8776 350 } else
gromero@8776 351 return 0;
gromero@8776 352 }
duke@435 353 };
duke@435 354
duke@435 355
zgu@3900 356 class PlatformEvent : public CHeapObj<mtInternal> {
duke@435 357 private:
duke@435 358 double CachePad [4] ; // increase odds that _mutex is sole occupant of cache line
duke@435 359 volatile int _Event ;
duke@435 360 volatile int _nParked ;
duke@435 361 pthread_mutex_t _mutex [1] ;
duke@435 362 pthread_cond_t _cond [1] ;
duke@435 363 double PostPad [2] ;
duke@435 364 Thread * _Assoc ;
duke@435 365
duke@435 366 public: // TODO-FIXME: make dtor private
duke@435 367 ~PlatformEvent() { guarantee (0, "invariant") ; }
duke@435 368
duke@435 369 public:
duke@435 370 PlatformEvent() {
duke@435 371 int status;
dholmes@5679 372 status = pthread_cond_init (_cond, os::Linux::condAttr());
duke@435 373 assert_status(status == 0, status, "cond_init");
duke@435 374 status = pthread_mutex_init (_mutex, NULL);
duke@435 375 assert_status(status == 0, status, "mutex_init");
duke@435 376 _Event = 0 ;
duke@435 377 _nParked = 0 ;
duke@435 378 _Assoc = NULL ;
duke@435 379 }
duke@435 380
duke@435 381 // Use caution with reset() and fired() -- they may require MEMBARs
duke@435 382 void reset() { _Event = 0 ; }
duke@435 383 int fired() { return _Event; }
duke@435 384 void park () ;
duke@435 385 void unpark () ;
duke@435 386 int TryPark () ;
dholmes@5679 387 int park (jlong millis) ; // relative timed-wait only
duke@435 388 void SetAssociation (Thread * a) { _Assoc = a ; }
duke@435 389 } ;
duke@435 390
zgu@3900 391 class PlatformParker : public CHeapObj<mtInternal> {
duke@435 392 protected:
dholmes@5679 393 enum {
dholmes@5679 394 REL_INDEX = 0,
dholmes@5679 395 ABS_INDEX = 1
dholmes@5679 396 };
dholmes@5679 397 int _cur_index; // which cond is in use: -1, 0, 1
duke@435 398 pthread_mutex_t _mutex [1] ;
dholmes@5679 399 pthread_cond_t _cond [2] ; // one for relative times and one for abs.
duke@435 400
duke@435 401 public: // TODO-FIXME: make dtor private
duke@435 402 ~PlatformParker() { guarantee (0, "invariant") ; }
duke@435 403
duke@435 404 public:
duke@435 405 PlatformParker() {
duke@435 406 int status;
dholmes@5679 407 status = pthread_cond_init (&_cond[REL_INDEX], os::Linux::condAttr());
dholmes@5679 408 assert_status(status == 0, status, "cond_init rel");
dholmes@5679 409 status = pthread_cond_init (&_cond[ABS_INDEX], NULL);
dholmes@5679 410 assert_status(status == 0, status, "cond_init abs");
duke@435 411 status = pthread_mutex_init (_mutex, NULL);
duke@435 412 assert_status(status == 0, status, "mutex_init");
dholmes@5679 413 _cur_index = -1; // mark as unused
duke@435 414 }
sla@5237 415 };
stefank@2314 416
stefank@2314 417 #endif // OS_LINUX_VM_OS_LINUX_HPP

mercurial