hotspot/src/os/bsd/vm/os_bsd.hpp
changeset 26683 a02753d5a0b2
parent 25472 381638db28e6
child 26684 d1221849ea3d
equal deleted inserted replaced
26331:8f17e084029b 26683:a02753d5a0b2
   106   //
   106   //
   107   // This interface should be declared in os_bsd_i486.hpp, but
   107   // This interface should be declared in os_bsd_i486.hpp, but
   108   // that file provides extensions to the os class and not the
   108   // that file provides extensions to the os class and not the
   109   // Bsd class.
   109   // Bsd class.
   110   static ExtendedPC fetch_frame_from_ucontext(Thread* thread, ucontext_t* uc,
   110   static ExtendedPC fetch_frame_from_ucontext(Thread* thread, ucontext_t* uc,
   111     intptr_t** ret_sp, intptr_t** ret_fp);
   111                                               intptr_t** ret_sp, intptr_t** ret_fp);
   112 
   112 
   113   // This boolean allows users to forward their own non-matching signals
   113   // This boolean allows users to forward their own non-matching signals
   114   // to JVM_handle_bsd_signal, harmlessly.
   114   // to JVM_handle_bsd_signal, harmlessly.
   115   static bool signal_handlers_are_installed;
   115   static bool signal_handlers_are_installed;
   116 
   116 
   145   // none present
   145   // none present
   146 
   146 
   147   // BsdThreads work-around for 6292965
   147   // BsdThreads work-around for 6292965
   148   static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
   148   static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
   149 
   149 
   150 private:
   150  private:
   151   typedef int (*sched_getcpu_func_t)(void);
   151   typedef int (*sched_getcpu_func_t)(void);
   152   typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
   152   typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
   153   typedef int (*numa_max_node_func_t)(void);
   153   typedef int (*numa_max_node_func_t)(void);
   154   typedef int (*numa_available_func_t)(void);
   154   typedef int (*numa_available_func_t)(void);
   155   typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
   155   typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
   168   static void set_numa_max_node(numa_max_node_func_t func) { _numa_max_node = func; }
   168   static void set_numa_max_node(numa_max_node_func_t func) { _numa_max_node = func; }
   169   static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
   169   static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
   170   static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
   170   static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
   171   static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
   171   static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
   172   static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
   172   static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
   173 public:
   173  public:
   174   static int sched_getcpu()  { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
   174   static int sched_getcpu()  { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
   175   static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
   175   static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
   176     return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
   176     return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
   177   }
   177   }
   178   static int numa_max_node() { return _numa_max_node != NULL ? _numa_max_node() : -1; }
   178   static int numa_max_node() { return _numa_max_node != NULL ? _numa_max_node() : -1; }
   188   static int get_node_by_cpu(int cpu_id);
   188   static int get_node_by_cpu(int cpu_id);
   189 };
   189 };
   190 
   190 
   191 
   191 
   192 class PlatformEvent : public CHeapObj<mtInternal> {
   192 class PlatformEvent : public CHeapObj<mtInternal> {
   193   private:
   193  private:
   194     double CachePad[4];   // increase odds that _mutex is sole occupant of cache line
   194   double CachePad[4];   // increase odds that _mutex is sole occupant of cache line
   195     volatile int _Event;
   195   volatile int _Event;
   196     volatile int _nParked;
   196   volatile int _nParked;
   197     pthread_mutex_t _mutex[1];
   197   pthread_mutex_t _mutex[1];
   198     pthread_cond_t  _cond[1];
   198   pthread_cond_t  _cond[1];
   199     double PostPad[2];
   199   double PostPad[2];
   200     Thread * _Assoc;
   200   Thread * _Assoc;
   201 
   201 
   202   public:       // TODO-FIXME: make dtor private
   202  public:       // TODO-FIXME: make dtor private
   203     ~PlatformEvent() { guarantee(0, "invariant"); }
   203   ~PlatformEvent() { guarantee(0, "invariant"); }
   204 
   204 
   205   public:
   205  public:
   206     PlatformEvent() {
   206   PlatformEvent() {
   207       int status;
   207     int status;
   208       status = pthread_cond_init (_cond, NULL);
   208     status = pthread_cond_init (_cond, NULL);
   209       assert_status(status == 0, status, "cond_init");
   209     assert_status(status == 0, status, "cond_init");
   210       status = pthread_mutex_init (_mutex, NULL);
   210     status = pthread_mutex_init (_mutex, NULL);
   211       assert_status(status == 0, status, "mutex_init");
   211     assert_status(status == 0, status, "mutex_init");
   212       _Event   = 0;
   212     _Event   = 0;
   213       _nParked = 0;
   213     _nParked = 0;
   214       _Assoc   = NULL;
   214     _Assoc   = NULL;
   215     }
   215   }
   216 
   216 
   217     // Use caution with reset() and fired() -- they may require MEMBARs
   217   // Use caution with reset() and fired() -- they may require MEMBARs
   218     void reset() { _Event = 0; }
   218   void reset() { _Event = 0; }
   219     int  fired() { return _Event; }
   219   int  fired() { return _Event; }
   220     void park();
   220   void park();
   221     void unpark();
   221   void unpark();
   222     int  park(jlong millis);
   222   int  park(jlong millis);
   223     void SetAssociation(Thread * a) { _Assoc = a; }
   223   void SetAssociation(Thread * a) { _Assoc = a; }
   224 };
   224 };
   225 
   225 
   226 class PlatformParker : public CHeapObj<mtInternal> {
   226 class PlatformParker : public CHeapObj<mtInternal> {
   227   protected:
   227  protected:
   228     pthread_mutex_t _mutex[1];
   228   pthread_mutex_t _mutex[1];
   229     pthread_cond_t  _cond[1];
   229   pthread_cond_t  _cond[1];
   230 
   230 
   231   public:       // TODO-FIXME: make dtor private
   231  public:       // TODO-FIXME: make dtor private
   232     ~PlatformParker() { guarantee(0, "invariant"); }
   232   ~PlatformParker() { guarantee(0, "invariant"); }
   233 
   233 
   234   public:
   234  public:
   235     PlatformParker() {
   235   PlatformParker() {
   236       int status;
   236     int status;
   237       status = pthread_cond_init (_cond, NULL);
   237     status = pthread_cond_init (_cond, NULL);
   238       assert_status(status == 0, status, "cond_init");
   238     assert_status(status == 0, status, "cond_init");
   239       status = pthread_mutex_init (_mutex, NULL);
   239     status = pthread_mutex_init (_mutex, NULL);
   240       assert_status(status == 0, status, "mutex_init");
   240     assert_status(status == 0, status, "mutex_init");
   241     }
   241   }
   242 };
   242 };
   243 
   243 
   244 #endif // OS_BSD_VM_OS_BSD_HPP
   244 #endif // OS_BSD_VM_OS_BSD_HPP