pthread5.c running creating thread 0 creating thread 1 creating thread 2 creating thread 3 waiting for threads to reach first barrier in barrier nb=1 of np=5 about to cond wait thread 0 at first barrier in barrier nb=2 of np=5 about to cond wait thread 1 at first barrier in barrier nb=3 of np=5 about to cond wait thread 2 at first barrier in barrier nb=4 of np=5 about to cond wait thread 3 at first barrier in barrier nb=5 of np=5 about to broadcast thread 3 running after first barrier thread 3 at second barrier in barrier nb=1 of np=5 about to cond wait thread 1 running after first barrier thread 1 at second barrier in barrier nb=2 of np=5 about to cond wait all threads finished first task results[0]=0 results[1]=20 results[2]=0 results[3]=40 wait for all threads to finish second task in barrier nb=3 of np=5 about to cond wait thread 2 running after first barrier thread 2 at second barrier in barrier nb=4 of np=5 about to cond wait thread 0 running after first barrier thread 0 at second barrier in barrier nb=5 of np=5 about to broadcast all threads finished second task final results[0]=10 final results[1]=20 final results[2]=30 final results[3]=40 wait for all threads to finish third task in barrier nb=1 of np=5 about to cond wait thread 1 running after second barrier thread 1 at third barrier in barrier nb=2 of np=5 about to cond wait thread 2 running after second barrier thread 2 at third barrier in barrier nb=3 of np=5 about to cond wait thread 3 running after second barrier thread 3 at third barrier in barrier nb=4 of np=5 about to cond wait thread 0 running after second barrier thread 0 at third barrier in barrier nb=5 of np=5 about to broadcast thread 1 running after third barrier thread 1 at fourth barrier in barrier nb=1 of np=5 about to cond wait thread 2 running after third barrier thread 2 at fourth barrier in barrier nb=2 of np=5 about to cond wait all threads finished third task in barrier nb=3 of np=5 about to cond wait thread 3 running after third barrier thread 3 at fourth barrier in barrier nb=4 of np=5 about to cond wait thread 0 running after third barrier thread 0 at fourth barrier in barrier nb=5 of np=5 about to broadcast final results[0]=1000 final results[1]=2000 final results[2]=3000 final results[3]=4000 master exiting