Operating System - HP-UX
1828273 Members
3303 Online
109975 Solutions
New Discussion

Max number of lock on 1 file

 
SOLVED
Go to solution
Andrew Beal
Frequent Advisor

Max number of lock on 1 file

Hi,

appart from the nflocks kernel paramater is there any other restrictions on how many locks you can have on one particular file at any time?

Thanks in advance,

Andrew
4 REPLIES 4
Steven E. Protter
Exalted Contributor
Solution

Re: Max number of lock on 1 file

Probably not.

There are lots of kinds of locks.

Your database app can lock a row in a table and there really is only one lock on the file.

nflocks as I understand it(probably not so well) is the total number of locks on the ENTIRE system.

I don't think you can really lock an individual file more than once at the same time.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sanjiv Sharma_1
Honored Contributor

Re: Max number of lock on 1 file

There should be only one lock on a file at a time.
Everything is possible
A. Clay Stephenson
Acclaimed Contributor

Re: Max number of lock on 1 file

With one exception the answer is no. The system can refuse to lock a portion of a file that would cause a system deadlock.

From the lockf man page:
A potential for deadlock occurs if a process controlling a locked resource is put to sleep by accessing the locked resource of another process.

You should also note that the same process might hold locks on many regions of the same file so that the total number of locks might be unexpectedly large.

The way to answer your sort of question, in general, is to consult the man pages (lockf and fcntl) in this case and look at all the reasons that a system call might fail and how errno is set under those conditions.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: Max number of lock on 1 file

The other thing to note is that (assuming nflocks is big enough), one could have individual locks on every byte of a file -- either a single process or many processes. I'm not saying that is very smart but it is certainly possible. Lockf() permits regions as small as 1 byte.
If it ain't broke, I can fix that.