On Wed Apr 16 21:59:07 2025 +0000, Matteo Bruni wrote:
I guess we could, although in practice it doesn't seem necessary. The following ok() generates a couple of function calls (the first one being to `winetest_get_thread_data()`) which basically force sequencing already. In general, the idea here is to make sure that the work related to the first `ok()` call doesn't allow the second `ok()` to succeed, which could happen if e.g. one runs the test with `WINETEST_REPORT_SUCCESS=1`, since in that case there's a syscall involved and thus an opportunity for the APC to execute. An alternative is (and my original solution was) to swap the two `ok()` calls instead.
As its name implies, Kernel APCs are executed asynchronously, not just at the call/return of the system calls in the thread the APCs are dispatched to. For example, `IoCompleteRequest()` is supposed dispatch the completion promptly, or at least the next time the initiator process or thread is scheduled. This is why it's possible to busy-wait IO completion with the `HasOverlappedIoCompleted()` macro.