I would like to test reliability of system flock in a multi-threaded and concurrent environment as some suggest that they are not reliable (in comments).Thus I wrote this code which requests non-blocking exclusive lock, with multiple threads at the same time (well, almost same time). Is there better way to test flock mutex functionality, or how to be sure that it is always exclusive?use strict;use warnings;use autodie;use threads;use Time::HiRes qw(time sleep);use Fcntl qw(:flock);sub fo{ my $fh; open($fh, >, pop) && $fh }my $t = time();my $one = grep $_->join,  map async {    my $f = fo(/tmp/flock.test);    sleep 2+$t-time();    my $l = flock($f, LOCK_EX|LOCK_NB);    sleep 1;    return $l;  }, 1..90;# should always be 1print $one is 1\n;
Reliability of flock mutex (LOCK_EX|LOCK_NB)
perl;file system;locking;concurrency