Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Aug 1999 01:21:09 +0900
From:      "Daniel C. Sobral" <dcs@newsguy.com>
To:        Greg Lehey <grog@lemis.com>
Cc:        Poul-Henning Kamp <phk@critter.freebsd.dk>, Matthew Dillon <dillon@apollo.backplane.com>, FreeBSD Hackers <hackers@FreeBSD.org>, FreeBSD Committers <cvs-committers@FreeBSD.org>, Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Subject:   Re: Mandatory locking?
Message-ID:  <37C174F5.2D8AEEB1@newsguy.com>
References:  <19990823162813.I83273@freebie.lemis.com> <7569.935394460@critter.freebsd.dk> <19990823174345.J83273@freebie.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Greg Lehey wrote:
> 
> all done in the kernel anyway.  In userland, we'd use a different
> example:
> 
>   I make a number of financial transactions over the Internet.  In
>   each case, the system checks my account balance, transfers the money
>   and deducts it from my account:
> 
>   1.  Check balance.
>   2.  Perform transfer.
>   3.  Write updated balance back.
> 
> Again, if we have two concurrent transactions, we stand to gain money:
> the updated balance is likely not to know about the other transaction,
> and will thus "forget" one of the deductions.
> 
> Now I suppose you're going to come and say that this is bad
> programming, and advisory locking would do the job if the software is
> written right.  Correct.  You could also use the same argument to say
> that memory protection isn't necessary, because a correctly written
> program doesn't overwrite other processes address space.  It's the
> same thing: file protection belongs in the kernel.

Well, I'd say advisory lock does the job if the software is written
right, and if the software is not written right, mandatory locking
won't help.

Let's give an example. You right a program using mandatory locking
making access to a file. I write an "incorrect" program accessing
that file. 

I garantee you that the file is going to be screwed up, because I
intend to write random output to it as soon as I get access to it.
After all, if I'm incorrect, I'm allowed to do anything.

--
Daniel C. Sobral			(8-DCS)
dcs@newsguy.com
dcs@freebsd.org

	- Come on.
	- Where are we going?
	- To get what you came for.
	- What's that?
	- Me.




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?37C174F5.2D8AEEB1>