Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Aug 1999 09:48:03 +0530
From:      "Biju Susmer" <bee@wipinfo.soft.net>
To:        "'Greg Lehey'" <grog@lemis.com>, "'Biju Susmer'" <bee@wipinfo.soft.net>
Cc:        "'FreeBSD Hackers'" <hackers@FreeBSD.ORG>
Subject:   RE: Mandatory locking?
Message-ID:  <000401beeeb0$d3fd4c00$88291fac@wipro.tcpn.com>
In-Reply-To: <19990825125221.I83273@freebie.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help


>
> This isn't locking, it's access exclusion.  It's also not correct for
> NSK.

  what is the difference between locking and access exclusion? i was thinking
both are same (locking implies access exclusion). in other words, My idea of
mandatory locking is same as exclusive access to the file. are we in sync? else
tell me what exactly u mean by "Mandatory locking".

>   NSK's OPEN procedure allows the following possibilities:
>   - shared access.  Any process can open the file unless another
>     process has it opened with a different access.
>   - exclusive access.  Only this process can open the file.  If it's
>     already open, the open call will fail.
>   - protected access.  Only this process can have the file open for
>     write.  If it's already open for writing, the open call will fail.
>

    Fine. This is true. i didn't want to give too much details. What i want to
tell is, there need not be a special call for lock. Combining lock/access
exclusion with open will be better.

>
> > Also, file need not be explicitly locked. Opening a file puts proper
> > lock.
>
> I'm not sure what you're saying here.  Opening a file doesn't lock it.

  same as above. put lock in open, not after getting fd. open should fail if
file is locked. This will help programs unaware of locking to behave better.

>
> > This kind of locking will solve most of the problems which are
> > pointed out.  Mandatory locking on a part of the file is in no way
> > better than advisory locking.
>
> Again, I'm not sure how much of this you understand.  I was thinking
> of doing something like NSK's LOCKREC function.
>

LOCKREC  locks records only. The problem is:
processes A & B. B doesn't know about locking (like 'cat')

  1. A opened file
  2. It locked some part of the file
  3. B opens and starts to write
  4. B reached the region which is lockd and write blocks
  5. A releases lock
  6. B's write is unblocked.

Here, how mandatory locking of a region help? isn't this same as advisory
locking? If opening itself fails coz of lock, the programs unaware of mandatory
locking will be forced to start from begining.

-Biju



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000401beeeb0$d3fd4c00$88291fac>