src/os/linux/vm/os_linux.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/os/linux/vm

src/os/linux/vm/os_linux.hpp

Print this page




 204   static void fast_thread_clock_init(void);
 205 
 206   static inline bool supports_monotonic_clock() {
 207     return _clock_gettime != NULL;
 208   }
 209 
 210   static int clock_gettime(clockid_t clock_id, struct timespec *tp) {
 211     return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
 212   }
 213 
 214   static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
 215     return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
 216   }
 217 
 218   static bool supports_fast_thread_cpu_time() {
 219     return _supports_fast_thread_cpu_time;
 220   }
 221 
 222   static jlong fast_thread_cpu_time(clockid_t clockid);
 223 







 224   // Stack repair handling
 225 
 226   // none present
 227 
 228   // LinuxThreads work-around for 6292965
 229   static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
 230 
 231 private:
 232   typedef int (*sched_getcpu_func_t)(void);
 233   typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
 234   typedef int (*numa_max_node_func_t)(void);
 235   typedef int (*numa_available_func_t)(void);
 236   typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
 237   typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
 238 
 239   static sched_getcpu_func_t _sched_getcpu;
 240   static numa_node_to_cpus_func_t _numa_node_to_cpus;
 241   static numa_max_node_func_t _numa_max_node;
 242   static numa_available_func_t _numa_available;
 243   static numa_tonode_memory_func_t _numa_tonode_memory;


 270   static int get_node_by_cpu(int cpu_id);
 271 };
 272 
 273 
 274 class PlatformEvent : public CHeapObj<mtInternal> {
 275   private:
 276     double CachePad [4] ;   // increase odds that _mutex is sole occupant of cache line
 277     volatile int _Event ;
 278     volatile int _nParked ;
 279     pthread_mutex_t _mutex  [1] ;
 280     pthread_cond_t  _cond   [1] ;
 281     double PostPad  [2] ;
 282     Thread * _Assoc ;
 283 
 284   public:       // TODO-FIXME: make dtor private
 285     ~PlatformEvent() { guarantee (0, "invariant") ; }
 286 
 287   public:
 288     PlatformEvent() {
 289       int status;
 290       status = pthread_cond_init (_cond, NULL);
 291       assert_status(status == 0, status, "cond_init");
 292       status = pthread_mutex_init (_mutex, NULL);
 293       assert_status(status == 0, status, "mutex_init");
 294       _Event   = 0 ;
 295       _nParked = 0 ;
 296       _Assoc   = NULL ;
 297     }
 298 
 299     // Use caution with reset() and fired() -- they may require MEMBARs
 300     void reset() { _Event = 0 ; }
 301     int  fired() { return _Event; }
 302     void park () ;
 303     void unpark () ;
 304     int  TryPark () ;
 305     int  park (jlong millis) ;
 306     void SetAssociation (Thread * a) { _Assoc = a ; }
 307 } ;
 308 
 309 class PlatformParker : public CHeapObj<mtInternal> {
 310   protected:





 311     pthread_mutex_t _mutex [1] ;
 312     pthread_cond_t  _cond  [1] ;
 313 
 314   public:       // TODO-FIXME: make dtor private
 315     ~PlatformParker() { guarantee (0, "invariant") ; }
 316 
 317   public:
 318     PlatformParker() {
 319       int status;
 320       status = pthread_cond_init (_cond, NULL);
 321       assert_status(status == 0, status, "cond_init");


 322       status = pthread_mutex_init (_mutex, NULL);
 323       assert_status(status == 0, status, "mutex_init");

 324     }
 325 };
 326 
 327 #endif // OS_LINUX_VM_OS_LINUX_HPP


 204   static void fast_thread_clock_init(void);
 205 
 206   static inline bool supports_monotonic_clock() {
 207     return _clock_gettime != NULL;
 208   }
 209 
 210   static int clock_gettime(clockid_t clock_id, struct timespec *tp) {
 211     return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
 212   }
 213 
 214   static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
 215     return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
 216   }
 217 
 218   static bool supports_fast_thread_cpu_time() {
 219     return _supports_fast_thread_cpu_time;
 220   }
 221 
 222   static jlong fast_thread_cpu_time(clockid_t clockid);
 223 
 224   // pthread_cond clock suppport
 225   private:
 226   static pthread_condattr_t _condattr[1];
 227 
 228   public:
 229   static pthread_condattr_t* condAttr() { return _condattr; }
 230   
 231   // Stack repair handling
 232 
 233   // none present
 234 
 235   // LinuxThreads work-around for 6292965
 236   static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
 237 
 238 private:
 239   typedef int (*sched_getcpu_func_t)(void);
 240   typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
 241   typedef int (*numa_max_node_func_t)(void);
 242   typedef int (*numa_available_func_t)(void);
 243   typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
 244   typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
 245 
 246   static sched_getcpu_func_t _sched_getcpu;
 247   static numa_node_to_cpus_func_t _numa_node_to_cpus;
 248   static numa_max_node_func_t _numa_max_node;
 249   static numa_available_func_t _numa_available;
 250   static numa_tonode_memory_func_t _numa_tonode_memory;


 277   static int get_node_by_cpu(int cpu_id);
 278 };
 279 
 280 
 281 class PlatformEvent : public CHeapObj<mtInternal> {
 282   private:
 283     double CachePad [4] ;   // increase odds that _mutex is sole occupant of cache line
 284     volatile int _Event ;
 285     volatile int _nParked ;
 286     pthread_mutex_t _mutex  [1] ;
 287     pthread_cond_t  _cond   [1] ;
 288     double PostPad  [2] ;
 289     Thread * _Assoc ;
 290 
 291   public:       // TODO-FIXME: make dtor private
 292     ~PlatformEvent() { guarantee (0, "invariant") ; }
 293 
 294   public:
 295     PlatformEvent() {
 296       int status;
 297       status = pthread_cond_init (_cond, os::Linux::condAttr());
 298       assert_status(status == 0, status, "cond_init");
 299       status = pthread_mutex_init (_mutex, NULL);
 300       assert_status(status == 0, status, "mutex_init");
 301       _Event   = 0 ;
 302       _nParked = 0 ;
 303       _Assoc   = NULL ;
 304     }
 305 
 306     // Use caution with reset() and fired() -- they may require MEMBARs
 307     void reset() { _Event = 0 ; }
 308     int  fired() { return _Event; }
 309     void park () ;
 310     void unpark () ;
 311     int  TryPark () ;
 312     int  park (jlong millis) ; // relative timed-wait only
 313     void SetAssociation (Thread * a) { _Assoc = a ; }
 314 } ;
 315 
 316 class PlatformParker : public CHeapObj<mtInternal> {
 317   protected:
 318     enum {
 319         REL_INDEX = 0,
 320         ABS_INDEX = 1
 321     };
 322     int _cur_index;  // which cond is in use: -1, 0, 1
 323     pthread_mutex_t _mutex [1] ;
 324     pthread_cond_t  _cond  [2] ; // one for relative times and one for abs.
 325 
 326   public:       // TODO-FIXME: make dtor private
 327     ~PlatformParker() { guarantee (0, "invariant") ; }
 328 
 329   public:
 330     PlatformParker() {
 331       int status;
 332       status = pthread_cond_init (&_cond[REL_INDEX], os::Linux::condAttr());
 333       assert_status(status == 0, status, "cond_init rel");
 334       status = pthread_cond_init (&_cond[ABS_INDEX], NULL);
 335       assert_status(status == 0, status, "cond_init abs");
 336       status = pthread_mutex_init (_mutex, NULL);
 337       assert_status(status == 0, status, "mutex_init");
 338       _cur_index = -1; // mark as unused
 339     }
 340 };
 341 
 342 #endif // OS_LINUX_VM_OS_LINUX_HPP
src/os/linux/vm/os_linux.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File