views:

71

answers:

1

Ritchie claims that file locking is not sufficient to prevent the confusion caused by programs such as editors that make a copy of a file while editing and then write the original file when done. Can you explain what he meant?

+2  A: 

He also said locks were not necessary, an assertion which most engineers consider to be untrue.

This was written by D.M. Ritchie and K. Thompson, The UNIX Time-Sharing System in The Bell System Technical Journal, Vol. 57, No. 6 (July-August 1978), Part 2, pp. 1905-1929.

The context of the remarks referred to the need for locking per the operating system's purposes. This was the era of Unix v6 (and maybe earlier) filesystems to provide file locking. Since the filesystem was not faced with large updateable databases, locking was not sufficient.

It was not necessary since the system kernel managed internal data structures with locks, and the system maintained "logical consistency" if two writers operated on the same file at once. I think the latter refers primarily to multiple processes appending to stdout or stderr.

wallyk