Modeling Dining Philosophers

17 views
Skip to first unread message

edward

unread,
Nov 11, 2009, 11:38:01 AM11/11/09
to Relacy Race Detector
Hi,

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)) If it does make sense,
then should this sleep() call somehow go through Relacy (eg.
rl_WaitForSingleObject) ?

Thanks,
-Edward

Dmitriy Vyukov

unread,
Nov 11, 2009, 11:55:45 AM11/11/09
to Relacy Race Detector
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

edward

unread,
Nov 11, 2009, 12:18:31 PM11/11/09
to Relacy Race Detector
That makes total sense. Thanks!

-Edward
Reply all
Reply to author
Forward
0 new messages