Draft

Racing, consecutive

Description:

This kata is part of the series about race conditions. The description describes a general case and is the same for all laps.

Story
Lap {1}{2}{3}{4}{5}...
Race condition, loosely speaking, is a situation when order of some actions isn't specified, but output of a program depends on it. Here is a code that has race condition problem and you should prove it.

Formal problem
Test cases section contain Race class which implements one or more public methods returning a stream (IEnumerable<int>). Whenever new value of returned stream is requested (via MoveNext() method of enumerator), the method itself runs until next yield return instruction.
Kata class implements a number of methods named ParallelN (where N varies).
Each Kata.ParallelN method represents certain usage case of Race class in parallel computation, where Kata class effectively works as sheduler.
Input:
Kata.ParallelN methods recieve a number of enumerators of streams returned by Race methods. These enumerators are already set on first elements of corresponding streams. Check test cases section to see details.
In at least one of Kata.ParallelN methods there is a way to order operations so that result is "unexpected" in some way. It may be code giving wrong answer, or Race class invariant being ruined, or some operations performed in wrong order. Find and exploit it.

Notes and hints
-- For C#, documentation on stream mechanism: IEnumerable, IEnumerator.
-- Wiki article: race condition.
-- Tests contain only one actual test, which in turn runs several usage scenarios and checks if any of them led to unexpected results.
-- Enumerators have a number of line where corresponding code has stopped in Current field.

Credits

More By Author:

Check out these other kata created by Absurdated

Stats:

CreatedMay 21, 2015
Warriors Trained31
Total Skips17
Total Code Submissions10
Total Times Completed5
C# Completions5
Total Stars0
% of votes with a positive feedback rating0% of 0
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes1
Ad
Contributors
  • Absurdated Avatar
Ad