2 # Copyright (C) 2006-2007, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
13 ? ( skip_all => 'broken on Win32' )
18 t/stm/basic_mt.t -- Multithreaded tests of STM ops and PMCs.
22 % prove t/stm/basic_mt.t
26 This file contains tests of the STM opcodes that require running
27 multiple threads at once.
31 pir_output_is( <<'CODE', <<'OUTPUT', "wait (simple)" );
47 print "invalid (not okay)\n"
77 _waiter = global "waiter"
79 wThr = new 'ParrotThread'
80 wThr.'run_clone'(_waiter, a)
82 sleep 1 # let it really wait
83 iThr = new 'ParrotThread'
84 iThr.'run_clone'(_incr, a)
94 skip( "Intermittent failures on all platforms", 2 );
96 pir_output_is( <<'CODE', <<'OUTPUT', "wait (simple, strings)" );
104 if $I0 < N goto retry
113 print "invalid (not okay)\n"
142 _incr = global "incr"
143 _waiter = global "waiter"
145 wThr = new 'ParrotThread'
146 wThr.'run_clone'(_waiter, a)
148 sleep 1 # let it really wait
149 iThr = new 'ParrotThread'
150 iThr.'run_clone'(_incr, a)
159 # This test is designed to trigger the internal deadlock detection.
160 # Occassionally both thread 1 and thread 2 should grab
161 # main's 'a' and main's 'b', respectively, and then try to acquire
162 # the other. Because of deadlock detection, exactly one of the two
163 # threads should quickly be aborted and the other should succeed.
164 # Without deadlock detection, the test will not complete quickly.
166 pir_output_like( <<'CODE', <<'OUTPUT', "get deadlock" );
180 # print "loop iteration "
199 _task = global "thread_task"
201 t1 = new 'ParrotThread'
202 t2 = new 'ParrotThread'
203 t1.'run_clone'(_task, a, b)
204 t2.'run_clone'(_task, b, a)
217 pir_output_is( <<'CODE', <<'OUTPUT', "wait + invalidate outer transcation" );
230 # we start a nested transcation here;
231 # the only we we ill get out of this loop
232 # is if stm_wait jumps to 'invalid'.
267 _incr = global "incr"
268 _waiter = global "waiter"
270 wThr = new 'ParrotThread'
271 wThr.'run_clone'(_waiter, a)
273 sleep 1 # let it really wait
274 iThr = new 'ParrotThread'
275 iThr.'run_clone'(_incr, a)
286 # cperl-indent-level: 4
289 # vim: expandtab shiftwidth=4: