src/share/vm/runtime/park.hpp

Print this page




   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  * Per-thread blocking support for JSR166. See the Java-level
  26  * Documentation for rationale. Basically, park acts like wait, unpark
  27  * like notify.
  28  *
  29  * 6271289 --
  30  * To avoid errors where an os thread expires but the JavaThread still
  31  * exists, Parkers are immortal (type-stable) and are recycled across
  32  * new threads.  This parallels the ParkEvent implementation.
  33  * Because park-unpark allow spurious wakeups it is harmless if an
  34  * unpark call unparks a new thread using the old Parker reference.
  35  *
  36  * In the future we'll want to think about eliminating Parker and using
  37  * ParkEvent instead.  There's considerable duplication between the two
  38  * services.
  39  *
  40  */
  41 
  42 class Parker : public os::PlatformParker {
  43 private:


 150        FreeNext       = NULL ;
 151        ListNext       = NULL ;
 152        ListPrev       = NULL ;
 153        OnList         = 0 ;
 154        TState         = 0 ;
 155        Notified       = 0 ;
 156        IsWaiting      = 0 ;
 157     }
 158 
 159     // We use placement-new to force ParkEvent instances to be
 160     // aligned on 256-byte address boundaries.  This ensures that the least
 161     // significant byte of a ParkEvent address is always 0.
 162 
 163     void * operator new (size_t sz) ;
 164     void operator delete (void * a) ;
 165 
 166   public:
 167     static ParkEvent * Allocate (Thread * t) ;
 168     static void Release (ParkEvent * e) ;
 169 } ;




   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_PARK_HPP
  26 #define SHARE_VM_RUNTIME_PARK_HPP
  27 
  28 #include "utilities/debug.hpp"
  29 #include "utilities/globalDefinitions.hpp"
  30 /*
  31  * Per-thread blocking support for JSR166. See the Java-level
  32  * Documentation for rationale. Basically, park acts like wait, unpark
  33  * like notify.
  34  *
  35  * 6271289 --
  36  * To avoid errors where an os thread expires but the JavaThread still
  37  * exists, Parkers are immortal (type-stable) and are recycled across
  38  * new threads.  This parallels the ParkEvent implementation.
  39  * Because park-unpark allow spurious wakeups it is harmless if an
  40  * unpark call unparks a new thread using the old Parker reference.
  41  *
  42  * In the future we'll want to think about eliminating Parker and using
  43  * ParkEvent instead.  There's considerable duplication between the two
  44  * services.
  45  *
  46  */
  47 
  48 class Parker : public os::PlatformParker {
  49 private:


 156        FreeNext       = NULL ;
 157        ListNext       = NULL ;
 158        ListPrev       = NULL ;
 159        OnList         = 0 ;
 160        TState         = 0 ;
 161        Notified       = 0 ;
 162        IsWaiting      = 0 ;
 163     }
 164 
 165     // We use placement-new to force ParkEvent instances to be
 166     // aligned on 256-byte address boundaries.  This ensures that the least
 167     // significant byte of a ParkEvent address is always 0.
 168 
 169     void * operator new (size_t sz) ;
 170     void operator delete (void * a) ;
 171 
 172   public:
 173     static ParkEvent * Allocate (Thread * t) ;
 174     static void Release (ParkEvent * e) ;
 175 } ;
 176 
 177 #endif // SHARE_VM_RUNTIME_PARK_HPP