Science Fair Projects Ideas - File locking

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

File locking

File locking is a mechanism that enforces access to a computer file by only one user at any specific time. The purpose of locking is to prevent the classic "interceding update " scenario.

The interceding update problem may be illustrated as in the following example: Process 'A' reads a customer record from a file containing account information, including the customer's account balance . Process 'B' now reads the same record from the same file. Process 'A' changes the account balance and writes the new value back to the file. However, process 'B' - which still has the original values of that customer record, makes a different change to its copy of the data (for example, changes the customer's phone number) and re-writes this data to the file. Process B's copy of the data, still containing the original account balance, overwrites the changes made by process A, reverting the account balance to its previous value and causing the update of the customer balance by process 'A' to be lost.

File locking prevents this problem by enforcing the serialization of update processes to any given file. Most operating systems support the concept of record locking which means that individual records within any given file may be locked, so increasing the number of concurrent update processes.

File locking in Windows

Program files are automatically locked uppon execution, thus preventing them from being deleted while running. This automatic locking also prevents open files in general from being deleted. Programs are also automatically notified if an open file is being modified by an external program.

The Windows locking approach can result in problems where the operating system or an application crashes without being terminated properly. This leads to a situation where access is denied to files even though they do not appear to be in use, because the operating system or a crashed application still has a lock on the file. The user will in this case have to terminate a program manually or reboot the system to remove the lock.

File locking in UNIX

Open files and programs are not automatically locked in UNIX. File locking does instead have to be done explicitly through the fcntl call, leaving file locking optional to use. Program files are therefore not automatically locked upon execution, leading to the possibility of programs being deleted while they are running. Files opened in one program may also be modified or deleted by an external program without any notification.

The UNIX locking approach leads to problems when an application crash, or is terminated unexpectedly. The application's locks will then continue to exist even though the application has terminated. Such persistent file-locks have to be removed manually by the user.

Last updated: 05-27-2005 14:25:21
10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice