Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix TODO test for RT #124793
This test suffers from a multithreading bug known as "lost wakeup".  A
lost wakeup situation occurs when you have one thread signaling a
condition variable, and another waiting on it.  What happens is that the
signal happens before the wait, and the thread waiting waits for a
signal that will never come. Normally, it occurs because one side forgot
to lock the mutex guarding the condition variable.  However, since
conditional variables are typically used to guard resources whose
condition changes, it can still occur when using locks.  The solution
was to have the waiting thread check an artificial resource for readiness,
and the signaling thread to make that artificial resource ready.
  • Loading branch information
hoelzro committed Sep 1, 2015
1 parent 6b38ee7 commit 6104874
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions S17-lowlevel/lock.t
Expand Up @@ -88,7 +88,6 @@ plan 8;
is @log.join(','), 'ale,porter,stout', 'Condition variable worked';
}

#?rakudo todo 'not sure this test is valid RT #124793'
{
my $times = 100;
my $tried;
Expand All @@ -98,15 +97,19 @@ plan 8;
my $c = $l.condition;
my $now1;
my $now2;
my $counter = 0;
my $t1 = Thread.start({
$l.protect({
$c.wait();
while $counter == 0 {
$c.wait();
}
$now1 = now;
});
});

my $t2 = Thread.start({
$l.protect({
$counter++;
$c.signal();
});
});
Expand Down

0 comments on commit 6104874

Please sign in to comment.