File locking is a mechanism that restricts access to files while they are in use. It prevents conflicts and data corruption when multiple processes access the same file. Locks can be shared or exclusive. Example: Preventing simultaneous writes to a database file.