On Nov 11, 7:38 pm, edward <
e4...@yahoo.com> wrote:
> Hi,
Hi Edward,
Thank you for your interest in Relacy.
> I'm modelling a Dining Philosophers test case. Does it make sense to
> introduce timers into the test case (as called for in some problem
> formulations)? eg. sleep(rl::rand(some_time))
No, you do not need to manually introduce sleep calls. Relacy itself
does something along the lines of introducing random sleeps here and
there. You just code an algorithm as you would do in production. But
when you run your production code on real OS/hardware you will be able
to cover only VERY small number of different thread interleavings. And
when you run it under Relacy you will be able to test VERY large
number of different thread interleavings automatically.
> If it does make sense,
> then should this sleep() call somehow go through Relacy (eg.
> rl_WaitForSingleObject) ?
If your algorithm itself requires sleep calls (for example you are
using spin waiting or exponential back-off on contention) then Yes,
the call has to through Relacy. There is a number of ways to express
it:
Sleep(milliseconds); // Win32
SwitchToThread(); // Win32
pthread_yield(); // POSIX
sched_yield(); // Unix
rl::yield(cycle_count); // Relacy specific
rl::backoff/linear_backoff/exp_backoff; // Relacy specific helper
objects
--
Dmitriy V'jukov