Linux file hierarchy - what's the best location to store lockfiles?
/dev/shm: It is nothing but implementation of traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result into speeding up things.
/var/lock) contains lock files, i.e. files indicating that a shared device or other system resource is in use and containing the identity of the process (PID) using it; this allows other processes to properly coordinate access to the shared device.
/tmp: is the location for temporary files as defined in the Filesystem Hierarchy Standard, which is followed by almost all Unix and Linux distributions. Since RAM is significantly faster than disk storage, you can use
/tmpfor the performance boost, if your process is I/O intensive and extensively uses temporary files.
/run/user/$uid: is created by
pam_systemdand used for storing files used by running processes for that user.
Coming to your question, you can definitely use
/run/lock directory to store your lock file.