They are all lock files. Link for more information.
Different applications and daemons create their lock files, if they need to protect themselves from crashing or from corrupting information.
For example:
/run/lock/whoopsie/lock
lock for whoopsie
, it is Ubuntu Error Reporting daemon. It collects information about crashes, so it need to protect some information from changes until it collects everything.
/proc/sys/dev/cdrom/lock
Lock file for you cdrom device. Only one application at a time can control cdrom
device, that's why it is there. The same thing for every devices.
/var/lib/dpkg/lock
/var/lib/apt/lists/lock
/var/cache/apt/archives/lock
Lock file for package managers. They usually blocking their sources database
Also a little quote from wikipedia
:
The following example illustrates the interceding update problem:
Process A reads a customer record from a file containing account information, including the customer's account balance and phone
number.
Process B now reads the same record from the same file so it has its own copy.
Process A changes the account balance in its copy of the customer record and writes the record back to the file.
Process B, which still has the original stale value for the account balance in its copy of the customer record, updates the account
balance and writes the customer record back to the file.
Process B has now written its stale account-balance value to the file, causing the changes made by process A to be lost.
This is one of examples. There many other situations that can lead to a problem. That's why OS need lock files