Hi As I understand it most VMs poll for safepoints by using memory management tricks to page fault polling threads. A page is set aside to read from and whenever a safepoint is desired the page is set to be unreadable.
But can't a number of other hardware traps be used instead https://wiki.osdev.org/Exceptions ? Not sure if a conditional jump to a trapping debug instruction would be slow or not. Also why not read from a pointer to a page instead of reading directly? That way only a an atomic write to a pointer is needed instead of a whole memory protection syscall. Also an atomicly written boolean flag is only one of many possible types of branches. You could have an indirect call or possibly jump and just overwrite a function pointer to install your handler for example. The standard way of doing things seems pretty sensible but it's just I've never actually seen a concrete comparison. Basically in pseudocode why void poll() { page[0]; } void trap() { mprotect(page, 0); } over void poll() { page[0]; } void trap() { page = 0; } or void poll() { 1 / bit; } void trap() { bit = 0; } And why void poll() { if (flag) dostuff(); } over void poll() { f(); } void trap() { f = handler; } Or void poll() { if (flag) __builtin_trao(); } Probably makes sense to do safepoint polls the standard way but I've never seen a detailed comparison exactly why. -- You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web, visit https://groups.google.com/d/msgid/mechanical-sympathy/5a36e38d-3811-4663-a7d5-b9ac4897404d%40googlegroups.com.
