manojsahu4u / multithreadedtc

Automatically exported from code.google.com/p/multithreadedtc
0 stars 0 forks source link

Clock advances too early #7

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create two threads, each advancing the clock using waitForTick
2. assertTick for the tick specified in 1.
3. repeat often

What is the expected output? What do you see instead?
This should always succeed. Instead, sometimes you have an "assertion failed", 
because the clock has advanced too far.

What version of the product are you using? On what operating system?
MultithreadedTC-1.01 on Linux multiprocessor. Haven't seen this error on 
Windows XP dual core.

Please provide any additional information below.

I think there might be a race condition between the clock cycle that checks for 
blocked threads and Java scheduling the thread that should resume after 
waitForTick.

Example output (here only one thread 2 is in waitForTick(1)):

  Typical (correct case):
    thread 2 is waiting for time 1
    thread 1 is waiting for time 2
    thread 1 is in state WAITING
    thread 2 is in state WAITING
    thread 1 is in state WAITING
    thread 2 is in state WAITING
    Time is now 1
    thread 1 is waiting for time 2
    Releasing thread 2 at time 1
    thread 1 is in state WAITING
    thread 2 is in state WAITING
    thread 1 is in state WAITING
    thread 2 is in state WAITING

  Sometimes (bad case):
    thread 2 is waiting for time 1
    thread 1 is waiting for time 2
    thread 1 is in state WAITING
    thread 2 is in state WAITING
    thread 1 is in state WAITING
    thread 2 is in state WAITING
    Time is now 1
    thread 1 is waiting for time 2
    thread 1 is in state WAITING
    thread 2 is in state BLOCKED
    thread 1 is in state WAITING
    thread 2 is in state BLOCKED
    Time is now 2

In the above output one can see, that the "Releasing thread 2" message is 
missing.

Original issue reported on code.google.com by m5knei...@googlemail.com on 14 Jul 2010 at 11:57

GoogleCodeExporter commented 9 years ago
Hi, your description sounds like the existing TestMetronomeOrder. I have tried 
running it 100 times on a Linux box, and the test passes. Could you please 
attach a minimal test case that I can use to reproduce this? Thanks.

Original comment by tom...@google.com on 11 Jun 2011 at 9:33