Even some BIFs and NIFs (BIF are mostly just an built-in NIFs) can yield [1]
and choose to reschedule themselves later. But inside the C code it is voluntary, of course. An example of this can be seen when running hash functions [2].
Another interesting idea is that a NIF which may not reschedule themselves with yield, can still signal the scheduler that they are consuming so many "reductions" if they did some lengthy work. So if, say, they run for 10 msec, they might want to bump the reduction counter a bit: enif_consume_timeslice. Otherwise a tight recursive loop calling the same NIF could still effectively block the VM.
Writes in MongoDB are persisted before the server returns acknowledgement. For a typical replica set deployment, this additionally means replicated and made durable on disk for a majority of nodes.
MongoDB has tunable durability guarantees; clients can opt-out of this behavior.
The layers are deep, but this is the function that handles waiting before acknowledgement: