< prev index next >

src/hotspot/share/runtime/osThread.hpp

Print this page




  45   ALLOCATED,                    // Memory has been allocated but not initialized
  46   INITIALIZED,                  // The thread has been initialized but yet started
  47   RUNNABLE,                     // Has been started and is runnable, but not necessarily running
  48   MONITOR_WAIT,                 // Waiting on a contended monitor lock
  49   CONDVAR_WAIT,                 // Waiting on a condition variable
  50   OBJECT_WAIT,                  // Waiting on an Object.wait() call
  51   BREAKPOINTED,                 // Suspended at breakpoint
  52   SLEEPING,                     // Thread.sleep()
  53   ZOMBIE                        // All done, but not reclaimed yet
  54 };
  55 
  56 typedef int (*OSThreadStartFunc)(void*);
  57 
  58 class OSThread: public CHeapObj<mtThread> {
  59   friend class VMStructs;
  60   friend class JVMCIVMStructs;
  61  private:
  62   OSThreadStartFunc _start_proc;  // Thread start routine
  63   void* _start_parm;              // Thread start routine parameter
  64   volatile ThreadState _state;    // Thread state *hint*
  65   volatile jint _interrupted;     // Thread.isInterrupted state
  66 
  67   // Note:  _interrupted must be jint, so that Java intrinsics can access it.
  68   // The value stored there must be either 0 or 1.  It must be possible
  69   // for Java to emulate Thread.currentThread().isInterrupted() by performing
  70   // the double indirection Thread::current()->_osthread->_interrupted.
  71 
  72   // Methods
  73  public:
  74   void set_state(ThreadState state)                { _state = state; }
  75   ThreadState get_state()                          { return _state; }
  76 
  77   OSThread(OSThreadStartFunc start_proc, void* start_parm);
  78   ~OSThread();
  79 
  80   // Accessors
  81   OSThreadStartFunc start_proc() const              { return _start_proc; }
  82   void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; }
  83   void* start_parm() const                          { return _start_parm; }
  84   void set_start_parm(void* start_parm)             { _start_parm = start_parm; }
  85   // These are specialized on Windows.
  86 #ifndef _WINDOWS
  87   volatile bool interrupted() const                 { return _interrupted != 0; }
  88   void set_interrupted(bool z)                      { _interrupted = z ? 1 : 0; }
  89 #endif
  90   // Printing
  91   void print_on(outputStream* st) const;
  92   void print() const;
  93 
  94   // For java intrinsics:
  95   static ByteSize interrupted_offset()            { return byte_offset_of(OSThread, _interrupted); }
  96 
  97   // Platform dependent stuff
  98 #include OS_HEADER(osThread)
  99 
 100  public:
 101   static ByteSize thread_id_offset()              { return byte_offset_of(OSThread, _thread_id); }
 102   static size_t thread_id_size()                  { return sizeof(thread_id_t); }
 103 
 104   thread_id_t thread_id() const                   { return _thread_id; }
 105 
 106   void set_thread_id(thread_id_t id)              { _thread_id = id; }
 107 
 108  private:
 109   // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
 110   // thread has a unique thread_id (BsdThreads or NPTL). It can be used
 111   // to access /proc.
 112   thread_id_t _thread_id;
 113 };
 114 
 115 




  45   ALLOCATED,                    // Memory has been allocated but not initialized
  46   INITIALIZED,                  // The thread has been initialized but yet started
  47   RUNNABLE,                     // Has been started and is runnable, but not necessarily running
  48   MONITOR_WAIT,                 // Waiting on a contended monitor lock
  49   CONDVAR_WAIT,                 // Waiting on a condition variable
  50   OBJECT_WAIT,                  // Waiting on an Object.wait() call
  51   BREAKPOINTED,                 // Suspended at breakpoint
  52   SLEEPING,                     // Thread.sleep()
  53   ZOMBIE                        // All done, but not reclaimed yet
  54 };
  55 
  56 typedef int (*OSThreadStartFunc)(void*);
  57 
  58 class OSThread: public CHeapObj<mtThread> {
  59   friend class VMStructs;
  60   friend class JVMCIVMStructs;
  61  private:
  62   OSThreadStartFunc _start_proc;  // Thread start routine
  63   void* _start_parm;              // Thread start routine parameter
  64   volatile ThreadState _state;    // Thread state *hint*






  65 
  66   // Methods
  67  public:
  68   void set_state(ThreadState state)                { _state = state; }
  69   ThreadState get_state()                          { return _state; }
  70 
  71   OSThread(OSThreadStartFunc start_proc, void* start_parm);
  72   ~OSThread();
  73 
  74   // Accessors
  75   OSThreadStartFunc start_proc() const              { return _start_proc; }
  76   void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; }
  77   void* start_parm() const                          { return _start_parm; }
  78   void set_start_parm(void* start_parm)             { _start_parm = start_parm; }
  79   // This is specialized on Windows.
  80 #ifndef _WINDOWS
  81   void set_interrupted(bool z)                      { /* nothing to do */ }

  82 #endif
  83   // Printing
  84   void print_on(outputStream* st) const;
  85   void print() const;



  86 
  87   // Platform dependent stuff
  88 #include OS_HEADER(osThread)
  89 
  90  public:
  91   static ByteSize thread_id_offset()              { return byte_offset_of(OSThread, _thread_id); }
  92   static size_t thread_id_size()                  { return sizeof(thread_id_t); }
  93 
  94   thread_id_t thread_id() const                   { return _thread_id; }
  95 
  96   void set_thread_id(thread_id_t id)              { _thread_id = id; }
  97 
  98  private:
  99   // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
 100   // thread has a unique thread_id (BsdThreads or NPTL). It can be used
 101   // to access /proc.
 102   thread_id_t _thread_id;
 103 };
 104 
 105 


< prev index next >