0N/A/*
2362N/A * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation.
0N/A *
2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2362N/A *
2362N/A */
0N/A
0N/A#ifndef SHARE_VM_RUNTIME_THREADCRITICAL_HPP
0N/A#define SHARE_VM_RUNTIME_THREADCRITICAL_HPP
0N/A
0N/A#include "memory/allocation.hpp"
0N/A
0N/A// ThreadCritical is used to protect short non-blocking critical sections.
0N/A// This class must use no vm facilities that require initialization.
0N/A// It is used very early in the vm's initialization, in allocation
0N/A// code and other areas. ThreadCritical regions are reentrant.
0N/A//
0N/A// Due to race conditions during vm exit, some of the os level
0N/A// synchronization primitives may not be deallocated at exit. It
502N/A// is a good plan to implement the platform dependent sections of
502N/A// code with resources that are recoverable during process
0N/A// cleanup by the os. Calling the initialize method before use
0N/A// is also problematic, it is best to use preinitialized primitives
0N/A// if possible. As an example:
0N/A//
0N/A// mutex_t mp = DEFAULTMUTEX;
4632N/A//
4632N/A// Also note that this class is declared as a StackObj to enforce
4632N/A// block structured short locks. It cannot be declared a ResourceObj
4632N/A// or CHeapObj, due to initialization issues.
0N/A
4632N/Aclass ThreadCritical : public StackObj {
4632N/A friend class os;
4632N/A private:
0N/A static void initialize();
0N/A static void release();
0N/A
0N/A public:
0N/A ThreadCritical();
0N/A ~ThreadCritical();
0N/A};
0N/A
0N/A#endif // SHARE_VM_RUNTIME_THREADCRITICAL_HPP
0N/A