Magic VLSI Layout Tool Version 8.3 *

locking


Control the behavior of file locking.

Usage:

locking [enable|disable]

Summary:

The locking command controls the behavior of file locking, which is an operating system-level protocol for preventing multiple processes from attempting to write to the same file at the same time. The behavior of the protocol is operating system dependent; for Linux/UNIX systems, this is a feature of the system fcntl() call. When a file is opened, the file descriptor is associated with an exclusive lock that prevents any other process from opening the same file for writing or appending. When using the file locking feature, two processes of magic cannot open the same file in read/write mode. The first process to open the file will have the exclusive right to alter the file contents. The second process may only view the layout in read-only mode.

Any cell that is read-only can be forced editable using the "cellname writeable" command option. Note that this does not make the file writeable if another process has obtained a lock on the file; it merely makes it editable, but to save the modified layout to disk would require that the name of the cell be changed or that the process holding the file lock releases it.

This is not a perfect protection mechanism, since the "cellname writeable" command option can subvert the intent of the file lock by allowing a cell to be read in read-only mode while another process has it locked; then, after the other process has released the lock, the file can be forced writeable and saved to the same file, potentially overwriting modifications made by the other process. In normal use cases, however, the file locking serves to prevent unintended overwriting of file modifications.

The file locking is enabled by default when magic starts up. Generally speaking, there is no reason to disable it. However, some operating systems have strict limits on the allowed number of open file descriptors, and it is possible for a sufficiently complex layout for there to be more files open than available file descriptors. In that case, the locking disable command option will prevent issues with the filesystem at the expense of file lock protection.

With no arguments, locking returns the state of the file locking, either "enabled" or "disabled".

Implementation Notes:

locking is implemented as a built-in command in magic from version tag 8.3.249.

See Also:

cellname

Return to command index

Last updated: January 1, 2022 at 3:11pm