/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_RUNTIME_VMTHREAD_HPP
#define SHARE_VM_RUNTIME_VMTHREAD_HPP
#include "runtime/perfData.hpp"
#include "runtime/vm_operations.hpp"
#ifdef TARGET_OS_FAMILY_linux
# include "thread_linux.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_solaris
# include "thread_solaris.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_windows
# include "thread_windows.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "thread_bsd.inline.hpp"
#endif
//
// Prioritized queue of VM operations.
//
// Encapsulates both queue management and
// and priority policy
//
private:
enum Priorities {
};
// We maintain a doubled linked list, with explicit count.
int _queue_counter;
// we also allow the vmThread to register the ops it has drained so we
// can scan them from oops_do
// Double-linked non-empty list insert.
void unlink(VM_Operation* q);
// Basic queue manipulation
bool queue_empty (int prio);
void drain_list_oops_do(OopClosure* f);
// lock-free query: may return the wrong answer but must not break
public:
// Highlevel operations. Encapsulates policy
// GC support
void oops_do(OopClosure* f);
};
//
// A single VMThread (the primordial thread) spawns all other threads
// and is itself used by other threads to offload heavy vm operations
// like scavenge, garbage_collect etc.
//
private:
static bool _should_terminate;
static bool _terminated;
public:
// Constructor
VMThread();
// Tester
bool is_VM_thread() const { return true; }
bool is_GC_thread() const { return true; }
// The ever running loop for the VMThread
void loop();
// Called to stop the VM thread
static void wait_for_vm_thread_exit();
// Execution of vm operation
// Returns the current vm operation if any.
// Returns the single instance of VMThread.
// GC support
// Debugging
void verify();
// Performance measurement
static PerfCounter* perf_accumulated_vm_operation_time() { return _perf_accumulated_vm_operation_time; }
// Entry for starting vm thread
virtual void run();
static void create();
static void destroy();
private:
// VM_Operation support
// Pointer to single-instance of VM thread
};
#endif // SHARE_VM_RUNTIME_VMTHREAD_HPP