[m-rev.] for review: Add barriers (for concurrency) to the standard library

Paul Bone paul at bone.id.au
Thu Apr 24 11:00:18 AEST 2014


On Wed, Apr 23, 2014 at 04:34:59PM +1000, Peter Wang wrote:
> On Wed, 23 Apr 2014 15:35:12 +1000, Paul Bone <paul at bone.id.au> wrote:
> > Mercury developers:
> > 
> > Normally adding test cases is straightforward, and I would like to add
> > Sebastian's test case.  However this involves concurrency and so output may
> > not be printed in the same order on every execution.  Normally I might do
> > something like sort the lines of the output and compare that with a sorted
> > expected output, however this only works for C and Java based grades.  It
> > doesn't work for C# which (at least on mono on my Linux workstation) can ix
> > the output threads within the same line.  If any one has any ideas for this
> > kind of test I'd be interested.  Otherwise I think I'll create a directory
> > of tests for concurrency that sort their outputs and are disabled for C#.
> 
> Hi Paul,
> 
> You need to add your own synchronisation if multiple threads are writing
> to the same output stream.  If that would perturb the test case then you
> can make each thread log to its own data structure and merge them later.

That sounds like a resonable fix for the C# grade.  Then depending on how I
write it out I can either write it by thread, or merge it in the program so
that I can check the output.

Thanks.

It seems obvious, I should have thought of this solution. :-(


-- 
Paul Bone



More information about the reviews mailing list