resource race_2_processes() var auditor_nap : int := 1 var num_accounts : int := 10000 var initial_value : real := 1000.00 var savings[1:num_accounts] : real := ([num_accounts] initial_value) write("bank is open with", num_accounts*initial_value, "in funds") process ATM var from_acc, to_acc : int var amount : real do true -> from_acc := int(random(1,num_accounts+1)) to_acc := int(random(1,num_accounts+1)) amount := random(savings[from_acc]) savings[from_acc] -:= amount savings[to_acc] +:= amount od end ATM process Auditor var total : real do true -> nap(1000*auditor_nap) total := 0 fa i := 1 to num_accounts -> total +:= savings[i] af write("age()=", age(), "total is ", total) od end Auditor end race_2_processes /* ............... Example compile and run(s) % sr -o race race.sr % ./race bank is open with 1.00000e+07 in funds age()= 2439 total is 9.99996e+06 age()= 4476 total is 9.99981e+06 age()= 7620 total is 1.00000e+07 age()= 10345 total is 1.00001e+07 age()= 12460 total is 9.99604e+06 age()= 15708 total is 1.00012e+07 age()= 17612 total is 1.00001e+07 age()= 20717 total is 1.00001e+07 age()= 23193 total is 1.00001e+07 age()= 26047 total is 1.00010e+07 age()= 28237 total is 1.00061e+07 age()= 31239 total is 9.99562e+06 age()= 33772 total is 1.00001e+07 age()= 36670 total is 1.00018e+07 age()= 40582 total is 9.99701e+06 age()= 42754 total is 1.00004e+07 age()= 45508 total is 1.00000e+07 age()= 47926 total is 1.00000e+07 ^C % sr -c race.sr % srl -o race -L 1 race_2_processes % ./race bank is open with 1.00000e+07 in funds age()= 5700 total is 1.00002e+07 age()= 12069 total is 9.97092e+06 age()= 22269 total is 9.97477e+06 age()= 29161 total is 1.00567e+07 age()= 36871 total is 9.96608e+06 age()= 41931 total is 9.97884e+06 age()= 48185 total is 9.99355e+06 ^C % sr -v MultiSR version 2.A, March 1992 % setenv SR_PARALLEL 2 % sr -o race race.sr % ./race bank is open with 1.00000e+07 in funds age()= 3390 total is 1.00160e+07 age()= 4560 total is 9.97778e+06 age()= 5730 total is 9.98940e+06 age()= 6940 total is 9.99495e+06 age()= 8140 total is 9.99133e+06 age()= 9310 total is 1.00336e+07 age()= 10470 total is 9.98013e+06 age()= 11670 total is 9.98069e+06 age()= 12890 total is 1.00335e+07 age()= 14050 total is 1.00077e+07 age()= 15220 total is 1.00050e+07 age()= 16380 total is 1.00346e+07 age()= 17580 total is 1.00222e+07 age()= 18760 total is 9.99019e+06 age()= 19930 total is 1.00050e+07 age()= 21090 total is 1.00023e+07 age()= 22250 total is 1.00141e+07 age()= 23410 total is 1.00090e+07 age()= 24610 total is 1.00156e+07 ^C */