Safepoints in the JVM

The quote comes from: http://blog.ragozin.info/2012/10/safepoints-in-hotspot-jvm.html

The Safepoint status check itself is implemented in a very tricky way. Conventional validation of memory variables will require costly memory barriers. However, the safepoint check is performed as the memory reads the barrier. then safepoint is required, the JVM unpacks the page with this provocative address ( which is processed by the JVMs handler ). Thus, HotSpot supports pipeline-compatible JTC code, provides the correct memory semantics (the unmap page causes a memory barrier for processing kernels).

I have some doubts:

  • From what I know, a page error is always handled by the OS (and, from what I understand, it can only be handled by the kernel because of security). So what does the author mean?
  • The second is very similar to the first: how can the JVM unmount a page?
+4
source share
1 answer
  • The OS primarily handles page errors. If the cause of this error is an illegal memory access attempted by the application, the OS sends a corresponding signal to the application, usually SIGSEGV.

    By default, SIGSEGV kills the application. However, the application can install its own signal handler. This is what the JVM does. It receives SIGSEGV, and if it sees that the signal is triggered by the safepoint polling instruction, the JVM pauses the current thread until the safepoint operation completes.

  • , munmap(). JVM , , mprotect() PROT_NONE.

+5

Source: https://habr.com/ru/post/1686307/


All Articles