No, because readers can always share the lock with other readers if
there is no writer waiting.
If you have one or more readers already holding the lock, with a writer
waiting, you have two choices: 1) let the new reader in under the
assumption that they'll be quick and won't extend the current "read"
usage by much, or 2) block the new reader until after any waiting
writers get a chance to get in. The first is called reader priority,
the second is writer priority.
The locks are written by glibc and the kernel. I haven't looked at
fcntl locking so I'm not sure where the bulk of the code is. I'd
suspect in the kernel.
The behaviour you describe is called "writer priority".
Again, this would be implementing writer priority.
POSIX doesn't guarantee either form, so if you need a writer-priority
lock then fcntl() isn't a good choice. In fact in most cases I suspect
you'll find that read/write locks are implemented as reader priority
since the expectation is that writes are infrequent.
Chris
--
Chris Friesen
Software Developer
GENBAND
chris.friesen@genband.comwww.genband.com
--