1

I used the following C++ functions to lock 1 byte of a file that is shared by server via SMB:

On Windows:

LockFileEx (h, LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK, 0, 1,0, &overlapped)

On Linux and Mac OS:

fcntl (fd, F_SETLK, &flockdesc)

On both locally shared files, and for a file shared over SMB, I got a successful lock in just 3 microseconds, whereas, for a file shared over NFS, I got a successful lock on the file in 26 milliseconds.

I am unable to understand how a process could get a lock in 3 microseconds over a network, since, to communicate to a server it should take at least some milliseconds of time, as observed in case of File shared over NFS.

Could anyone help me figure out why this is happening?

0 Answers0