@@ -1644,20 +1644,22 @@ void caml_reset_young_limit(caml_domain_state * dom_st)
16441644 achieves the proper synchronisation. */
16451645 atomic_exchange (& dom_st -> young_limit , (uintnat )trigger );
16461646
1647+ /* For non-delayable asynchronous actions, we immediately interrupt
1648+ the domain again. */
16471649 dom_internal * d = & all_domains [dom_st -> id ];
16481650 if (atomic_load_relaxed (& d -> interruptor .interrupt_pending )
16491651 || dom_st -> requested_minor_gc
16501652 || dom_st -> requested_major_slice
1651- || dom_st -> major_slice_epoch < atomic_load (& caml_major_slice_epoch )
1652- || atomic_load_relaxed (& dom_st -> requested_external_interrupt )) {
1653+ || dom_st -> major_slice_epoch < atomic_load (& caml_major_slice_epoch )) {
16531654 interrupt_domain_local (dom_st );
16541655 }
1655- /* We might be here due to a recently-recorded signal, so we
1656- need to remember that we must run signal handlers. In
1657- addition, in the case of long-running C code (that may
1658- regularly poll with caml_process_pending_actions), we want to
1659- force a query of all callbacks at every minor collection or
1660- major slice (similarly to the OCaml behaviour). */
1656+ /* We might be here due to a recently-recorded signal or forced
1657+ systhread switching, so we need to remember that we must run
1658+ signal handlers or systhread's yield. In addition, in the case of
1659+ long-running C code (that may regularly poll with
1660+ caml_process_pending_actions), we want to force a query of all
1661+ callbacks at every minor collection or major slice (similarly to
1662+ the OCaml behaviour). */
16611663 caml_set_action_pending (dom_st );
16621664}
16631665
@@ -1749,9 +1751,6 @@ void caml_poll_gc_work(void)
17491751 caml_poll_gc_work is called. */
17501752 }
17511753
1752- if (atomic_load_acquire (& d -> requested_external_interrupt )) {
1753- caml_domain_external_interrupt_hook ();
1754- }
17551754 caml_reset_young_limit (d );
17561755}
17571756
@@ -1769,6 +1768,14 @@ void caml_handle_gc_interrupt(void)
17691768 caml_poll_gc_work ();
17701769}
17711770
1771+ /* Preemptive systhread switching */
1772+ void caml_process_external_interrupt (void )
1773+ {
1774+ if (atomic_load_acquire (& Caml_state -> requested_external_interrupt )) {
1775+ caml_domain_external_interrupt_hook ();
1776+ }
1777+ }
1778+
17721779CAMLexport int caml_bt_is_in_blocking_section (void )
17731780{
17741781 uintnat status = atomic_load_acquire (& domain_self -> backup_thread_msg );
0 commit comments