Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

operating system

What are acyclic directories?

Muhammad Ashir

Acyclic directories are a generalization of the Tree directory structure. Acyclic directories allow files to have multiple parent directories; this means that multiple users can access the same file from different paths. However, it is important to note that the shared file is not a copy of the same file in two different directories.

Acyclic directories come in handy in situations where two programmers working together might need access to the same file. If one of the programmers makes any changes to the file, the changes will be visible to the other programmer as well.

A new directory entry called a link can be created in UNIX and UNIX-like systems. A link is essentially a pointer to another file or sub-directory. When we reference a file, the directory is searched for the relevant file, and if the directory is marked as a link, then the name of the file is included in the information.

Acyclic directories allow file sharing and make it easier to search for files because of different-different paths.

However, the deletion of files is complicated in acyclic directories. There are two ways in which a file can be deleted:

  • One option is to delete the file when any user deletes the file. However, this may lead to dangling pointers. The situation may become worse if the deleted space is reallocated to some new file, and the dangling pointers may now point to an arbitrary location in the new files.

  • The other option is to delete the link to the file. This mechanism needs some way of storing the list of links to the file. This list may become extremely large, so a better method is to keep a count of the links to the file. Whenever a link is deleted, the count is decremented, and when a new link is created, the count is incremented. The file can be deleted when the count becomes zero.


operating system


Muhammad Ashir
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring