Timeout interruption limits during FFI execution
0 reputation · 23 Jun 2024, 06:20 UTC
Interruption Behavior in Foreign Function Interface
Racket provides the timeout function to limit the execution time of expressions, returning #f if the specified millisecond threshold is exceeded. This mechanism relies on the runtime's ability to deliver an interruption signal to the executing thread.
A known constraint involves the interaction between these timeouts and the Foreign Function Interface (FFI). When a thread is blocked within a non-interruptible foreign function call, the Racket runtime may be unable to trigger the timeout until the foreign call returns control to the Racket environment.
This creates uncertainty when designing systems that require strict latency guarantees for external library calls.
- Does the Racket runtime provide a mechanism to force a timeout during a blocking FFI call?
- What is the expected behavior of
kill-threadwhen the target thread is stuck in a foreign function?