src/share/vm/runtime/osThread.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/osThread.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2010, 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  *


  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 // I'd make OSThread a ValueObj embedded in Thread to avoid an indirection, but
  57 // the assembler test in java.cpp expects that it can install the OSThread of
  58 // the main thread into its own Thread at will.
  59 
  60 
  61 class OSThread: public CHeapObj {
  62   friend class VMStructs;
  63  private:
  64   //void* _start_proc;            // Thread start routine
  65   OSThreadStartFunc _start_proc;  // Thread start routine
  66   void* _start_parm;              // Thread start routine parameter
  67   volatile ThreadState _state;    // Thread state *hint*
  68   jint _interrupted;              // Thread.isInterrupted state
  69 
  70   // Note:  _interrupted must be jint, so that Java intrinsics can access it.
  71   // The value stored there must be either 0 or 1.  It must be possible
  72   // for Java to emulate Thread.currentThread().isInterrupted() by performing
  73   // the double indirection Thread::current()->_osthread->_interrupted.
  74 
  75   // Methods
  76  public:
  77   void set_state(ThreadState state)                { _state = state; }
  78   ThreadState get_state()                          { return _state; }
  79 
  80   // Constructor
  81   OSThread(OSThreadStartFunc start_proc, void* start_parm);
  82 
  83   // Destructor
  84   ~OSThread();
  85 
  86   // Accessors
  87   OSThreadStartFunc start_proc() const              { return _start_proc; }
  88   void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; }
  89   void* start_parm() const                          { return _start_parm; }
  90   void set_start_parm(void* start_parm)             { _start_parm = start_parm; }
  91 
  92   bool interrupted() const                          { return _interrupted != 0; }
  93   void set_interrupted(bool z)                      { _interrupted = z ? 1 : 0; }
  94 
  95   // Printing
  96   void print_on(outputStream* st) const;
  97   void print() const                                { print_on(tty); }
  98 
  99   // For java intrinsics:
 100   static ByteSize interrupted_offset()            { return byte_offset_of(OSThread, _interrupted); }
 101 
 102   // Platform dependent stuff
 103 #ifdef TARGET_OS_FAMILY_linux
 104 # include "osThread_linux.hpp"
 105 #endif
 106 #ifdef TARGET_OS_FAMILY_solaris
 107 # include "osThread_solaris.hpp"
 108 #endif
 109 #ifdef TARGET_OS_FAMILY_windows
 110 # include "osThread_windows.hpp"
 111 #endif
 112 


   1 /*
   2  * Copyright (c) 1997, 2011, 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  *


  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 // I'd make OSThread a ValueObj embedded in Thread to avoid an indirection, but
  57 // the assembler test in java.cpp expects that it can install the OSThread of
  58 // the main thread into its own Thread at will.
  59 
  60 
  61 class OSThread: public CHeapObj {
  62   friend class VMStructs;
  63  private:
  64   //void* _start_proc;            // Thread start routine
  65   OSThreadStartFunc _start_proc;  // Thread start routine
  66   void* _start_parm;              // Thread start routine parameter
  67   volatile ThreadState _state;    // Thread state *hint*
  68   volatile jint _interrupted;     // Thread.isInterrupted state
  69 
  70   // Note:  _interrupted must be jint, so that Java intrinsics can access it.
  71   // The value stored there must be either 0 or 1.  It must be possible
  72   // for Java to emulate Thread.currentThread().isInterrupted() by performing
  73   // the double indirection Thread::current()->_osthread->_interrupted.
  74 
  75   // Methods
  76  public:
  77   void set_state(ThreadState state)                { _state = state; }
  78   ThreadState get_state()                          { return _state; }
  79 
  80   // Constructor
  81   OSThread(OSThreadStartFunc start_proc, void* start_parm);
  82 
  83   // Destructor
  84   ~OSThread();
  85 
  86   // Accessors
  87   OSThreadStartFunc start_proc() const              { return _start_proc; }
  88   void set_start_proc(OSThreadStartFunc start_proc) { _start_proc = start_proc; }
  89   void* start_parm() const                          { return _start_parm; }
  90   void set_start_parm(void* start_parm)             { _start_parm = start_parm; }
  91 
  92   volatile bool interrupted() const                 { return _interrupted != 0; }
  93   void set_interrupted(bool z)                      { _interrupted = z ? 1 : 0; }
  94 
  95   // Printing
  96   void print_on(outputStream* st) const;
  97   void print() const                                { print_on(tty); }
  98 
  99   // For java intrinsics:
 100   static ByteSize interrupted_offset()            { return byte_offset_of(OSThread, _interrupted); }
 101 
 102   // Platform dependent stuff
 103 #ifdef TARGET_OS_FAMILY_linux
 104 # include "osThread_linux.hpp"
 105 #endif
 106 #ifdef TARGET_OS_FAMILY_solaris
 107 # include "osThread_solaris.hpp"
 108 #endif
 109 #ifdef TARGET_OS_FAMILY_windows
 110 # include "osThread_windows.hpp"
 111 #endif
 112 


src/share/vm/runtime/osThread.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File