src/hotspot/share/runtime/vmThread.hpp
changeset 53020 c403f39ec349
parent 52877 9e041366c764
child 53244 9807daeb47c4
--- a/src/hotspot/share/runtime/vmThread.hpp	Thu Dec 13 10:35:09 2018 -0500
+++ b/src/hotspot/share/runtime/vmThread.hpp	Thu Dec 13 16:45:24 2018 +0100
@@ -27,6 +27,7 @@
 
 #include "runtime/perfData.hpp"
 #include "runtime/thread.hpp"
+#include "runtime/task.hpp"
 #include "runtime/vmOperations.hpp"
 
 //
@@ -84,6 +85,26 @@
 };
 
 
+// VM operation timeout handling: warn or abort the VM when VM operation takes
+// too long. Periodic tasks do not participate in safepoint protocol, and therefore
+// can fire when application threads are stopped.
+
+class VMOperationTimeoutTask : public PeriodicTask {
+private:
+  volatile int _armed;
+  jlong _arm_time;
+
+public:
+  VMOperationTimeoutTask(size_t interval_time) :
+          PeriodicTask(interval_time), _armed(0), _arm_time(0) {}
+
+  virtual void task();
+
+  bool is_armed();
+  void arm();
+  void disarm();
+};
+
 //
 // A single VMThread (the primordial thread) spawns all other threads
 // and is itself used by other threads to offload heavy vm operations
@@ -101,6 +122,8 @@
 
   static const char* _no_op_reason;
 
+  static VMOperationTimeoutTask* _timeout_task;
+
   static bool no_op_safepoint_needed(bool check_time);
 
   void evaluate_operation(VM_Operation* op);