< prev index next >

src/share/vm/runtime/osThread.hpp

Print this page
rev 11647 : 8161258: Simplify including platform files.
Summary: Include patform files with macros cpu_header() etc. Do various cleanups of macro usages. Remove _64/_32 from adlc generated files and platform .hpp files. Merge stubRoutines_x86*.hpp. Remove empty mutex_<os>* files.
Reviewed-by: dholmes, coleenp, kbarrett
   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_OSTHREAD_HPP
  26 #define SHARE_VM_RUNTIME_OSTHREAD_HPP
  27 
  28 #include "runtime/frame.hpp"
  29 #include "runtime/handles.hpp"
  30 #include "runtime/javaFrameAnchor.hpp"
  31 #include "runtime/objectMonitor.hpp"

  32 
  33 // The OSThread class holds OS-specific thread information.  It is equivalent
  34 // to the sys_thread_t structure of the classic JVM implementation.
  35 
  36 // The thread states represented by the ThreadState values are platform-specific
  37 // and are likely to be only approximate, because most OSes don't give you access
  38 // to precise thread state information.
  39 
  40 // Note: the ThreadState is legacy code and is not correctly implemented.
  41 // Uses of ThreadState need to be replaced by the state in the JavaThread.
  42 
  43 enum ThreadState {
  44   ALLOCATED,                    // Memory has been allocated but not initialized
  45   INITIALIZED,                  // The thread has been initialized but yet started
  46   RUNNABLE,                     // Has been started and is runnable, but not necessarily running
  47   MONITOR_WAIT,                 // Waiting on a contended monitor lock
  48   CONDVAR_WAIT,                 // Waiting on a condition variable
  49   OBJECT_WAIT,                  // Waiting on an Object.wait() call
  50   BREAKPOINTED,                 // Suspended at breakpoint
  51   SLEEPING,                     // Thread.sleep()


  79   OSThread(OSThreadStartFunc start_proc, void* start_parm);
  80   ~OSThread();
  81 
  82   // Accessors
  83   OSThreadStartFunc start_proc() const              { return _start_proc; }
  84   void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; }
  85   void* start_parm() const                          { return _start_parm; }
  86   void set_start_parm(void* start_parm)             { _start_parm = start_parm; }
  87 
  88   volatile bool interrupted() const                 { return _interrupted != 0; }
  89   void set_interrupted(bool z)                      { _interrupted = z ? 1 : 0; }
  90 
  91   // Printing
  92   void print_on(outputStream* st) const;
  93   void print() const                                { print_on(tty); }
  94 
  95   // For java intrinsics:
  96   static ByteSize interrupted_offset()            { return byte_offset_of(OSThread, _interrupted); }
  97 
  98   // Platform dependent stuff
  99 #ifdef TARGET_OS_FAMILY_linux
 100 # include "osThread_linux.hpp"
 101 #endif
 102 #ifdef TARGET_OS_FAMILY_solaris
 103 # include "osThread_solaris.hpp"
 104 #endif
 105 #ifdef TARGET_OS_FAMILY_windows
 106 # include "osThread_windows.hpp"
 107 #endif
 108 #ifdef TARGET_OS_FAMILY_aix
 109 # include "osThread_aix.hpp"
 110 #endif
 111 #ifdef TARGET_OS_FAMILY_bsd
 112 # include "osThread_bsd.hpp"
 113 #endif
 114 
 115  public:
 116   static ByteSize thread_id_offset()              { return byte_offset_of(OSThread, _thread_id); }
 117   static size_t thread_id_size()                  { return sizeof(thread_id_t); }
 118 
 119   thread_id_t thread_id() const                   { return _thread_id; }
 120 
 121   void set_thread_id(thread_id_t id)              { _thread_id = id; }
 122 
 123  private:
 124   // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
 125   // thread has a unique thread_id (BsdThreads or NPTL). It can be used
 126   // to access /proc.
 127   thread_id_t _thread_id;
 128 };
 129 
 130 
 131 // Utility class for use with condition variables:
 132 class OSThreadWaitState : public StackObj {
 133   OSThread*   _osthread;


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_OSTHREAD_HPP
  26 #define SHARE_VM_RUNTIME_OSTHREAD_HPP
  27 
  28 #include "runtime/frame.hpp"
  29 #include "runtime/handles.hpp"
  30 #include "runtime/javaFrameAnchor.hpp"
  31 #include "runtime/objectMonitor.hpp"
  32 #include "utilities/macros.hpp"
  33 
  34 // The OSThread class holds OS-specific thread information.  It is equivalent
  35 // to the sys_thread_t structure of the classic JVM implementation.
  36 
  37 // The thread states represented by the ThreadState values are platform-specific
  38 // and are likely to be only approximate, because most OSes don't give you access
  39 // to precise thread state information.
  40 
  41 // Note: the ThreadState is legacy code and is not correctly implemented.
  42 // Uses of ThreadState need to be replaced by the state in the JavaThread.
  43 
  44 enum ThreadState {
  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()


  80   OSThread(OSThreadStartFunc start_proc, void* start_parm);
  81   ~OSThread();
  82 
  83   // Accessors
  84   OSThreadStartFunc start_proc() const              { return _start_proc; }
  85   void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; }
  86   void* start_parm() const                          { return _start_parm; }
  87   void set_start_parm(void* start_parm)             { _start_parm = start_parm; }
  88 
  89   volatile bool interrupted() const                 { return _interrupted != 0; }
  90   void set_interrupted(bool z)                      { _interrupted = z ? 1 : 0; }
  91 
  92   // Printing
  93   void print_on(outputStream* st) const;
  94   void print() const                                { print_on(tty); }
  95 
  96   // For java intrinsics:
  97   static ByteSize interrupted_offset()            { return byte_offset_of(OSThread, _interrupted); }
  98 
  99   // Platform dependent stuff
 100 #include OS_HEADER(osThread)














 101 
 102  public:
 103   static ByteSize thread_id_offset()              { return byte_offset_of(OSThread, _thread_id); }
 104   static size_t thread_id_size()                  { return sizeof(thread_id_t); }
 105 
 106   thread_id_t thread_id() const                   { return _thread_id; }
 107 
 108   void set_thread_id(thread_id_t id)              { _thread_id = id; }
 109 
 110  private:
 111   // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
 112   // thread has a unique thread_id (BsdThreads or NPTL). It can be used
 113   // to access /proc.
 114   thread_id_t _thread_id;
 115 };
 116 
 117 
 118 // Utility class for use with condition variables:
 119 class OSThreadWaitState : public StackObj {
 120   OSThread*   _osthread;


< prev index next >