Closed MaximilianAlgehed closed 2 years ago
John:
It would be good to keep IOSim and IOSimPOR in step. Remember in that case that threadStatus races with anything that changes the status of the target thread, such as an uncaught exception, or an STM transaction in that thread that blocks. Or an STM transaction in a third thread what wakes up the target thread. (Not as bad as it sounds, IOSimPOR computes a wake-up effect for each thread step for this kind of purpose). Also the vector clock of the caller has to be updated to reflect a 'read' from the target thread. This stuff is very easy to get wrong.
Marcin:
IOSim and IOSimPOR are using the same free monad, the difference is in the interpreter. You would need to add a constructor to
SimA
and then extend the schedule functions inControl.Monad.IOSim.Internal
andControl.Monad.IOSimPOR.Internal
modules.
IOSim
runs one thread at a time until it's blocked or it terminates. EventhreadDelay
is implemented with usingSTM
(we have a draft PR which changes that, but we haven't finished exactly the IOSimPOR part). I think this will result in thatThreadRunning
is only returned when you ask the current thread (it could be a property to quick-check).We don't store information about threads that terminated, at least in IOSim (in
IOSimPOR
I think it's slightly different). We have to be careful with extending the overall state to minimize performance impact on large simulations (we have a bunch of such in ouroboros-network).io-sim
has some micro benchmarks too.
IOSim
can only block onSTM
orthrowTo
; We have a PR which implementsMVar
s usingTMVar
s, so one cannot relay onBlockedOnMVar
without extendingTVar
type.We don't store the reason why a thread is blocked, but extending that would be easy.
The threadStatus function is missing from the
io-classes
interface. We need it for an example inquickcheck-dynamic
but it is not urgent.