Implements read and write locks using fcntl