0% found this document useful (0 votes)
25 views3 pages

Drawings

Uploaded by

bharathraj01ja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Drawings

Uploaded by

bharathraj01ja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Single-Level Directory concept:

The single-level directory is the simplest directory structure where all files are stored in one directory. This
structure is easy to manage and understand, but it comes with significant limitations:

All files in the directory must have unique names. This can lead to conflicts when different users or programs
use the same name for files. For example, if two users name their files "test.txt," the system will face a
naming conflict.

As the number of files increases, managing them becomes more challenging. This is especially true in multi-
user systems, where users may create files with the same name, leading to confusion.

For a single user with many files, keeping track of all the file names in a single directory can be difficult,
particularly if the user has hundreds of files across multiple systems.

Two-Level Directory

- In a two-level directory system, each user has their own user file directory (UFD).

- The UFD for each user lists only the files specific to that user.

- The system has a Master File Directory (MFD), which is indexed by user names or account numbers.

- The MFD points to the UFD of each user.

- Each UFD contains only unique file names, but users can have files with the same name (e.g., both users
can have a file named test.txt).

- This avoids conflicts of file names across different users.

- When creating a file, the operating system checks the specific user’s UFD to ensure the file name is unique
within that user’s directory.

- When deleting a file, the system only searches within the user’s UFD to prevent accidentally deleting
other users' files with the same name.
- If access to files from different users is permitted, one user can reference files in another user’s UFD by
specifying the path (e.g., /userb/test.txt).

- A file’s location is defined by its path name, which includes both the user name and the file name.

- The path follows a hierarchical structure: MFD → UFD → File.

- The full path must be known to uniquely identify a file (e.g., /userb/test.txt).

- System files, such as loaders and compilers, are often stored in a special user directory (e.g., user 0).

- The operating system first searches the user’s own UFD for system files, and if not found, searches the
system’s special directory for them.

- The system can have a search path for locating files, including system files.

- The search path may contain multiple directories to search in sequence, which is common in UNIX and
Windows systems.

- Each user can have their own specific search path.

Disadvantages:

- The two-level directory structure isolates users from each other. This is good for independent users but
poses challenges if users need to cooperate or access each other’s files. and to enable access to another
user’s files, the user must specify the full path name.

Tree-Structured Directories:

- A tree-structured directory extends the two-level directory system to allow an arbitrary number of
subdirectories, offering greater flexibility for organizing files.

- The directory system has a root directory, and each file in the system has a unique path name, forming a
hierarchical structure.

- Directories can contain files or other subdirectories.

- A directory is treated as a special type of file, with a bit in each directory entry indicating whether the
entry is a file (0) or a subdirectory (1).

- Special system calls are used to create and delete directories.

4. Current Directory: - Each process has a current directory, which contains the files of interest to the process.

- When accessing a file, the current directory is searched. If the file is not found, the process may need to
specify a path name or change the current directory.

- Changing the current directory is done through a system call (change directory), which updates the
current directory to the specified one.

5. Path Names: - Absolute Path Name: Starts from the root directory and follows a path down to the file,
specifying each directory in the path.

- Relative Path Name: Defines a path from the current directory. For example, from root/spell/mail, the
relative path prt/first refers to the same file as the absolute path root/spell/mail/prt/first.

- Users can create subdirectories to organize their files, allowing them to impose a structure, such as having
separate directories for different topics or file types (e.g., source programs in one directory, binaries in
another).
7. Directory Deletion Policy:

- Empty Directory Deletion: A directory can be deleted if it is empty.

- Non-Empty Directory Deletion: If the directory contains files or subdirectories, there are two common
approaches:

- No Deletion Unless Empty: The directory can only be deleted after all files and subdirectories have been
removed, which may require recursive deletion.

- Delete All Contents**: Some systems allow the directory and its contents to be deleted with one
command (e.g., UNIX's rm command). While more convenient, this approach can be risky if issued by
mistake, as it results in the removal of an entire directory structure.

- Users can access files belonging to other users by specifying the correct path name.

- Users may either use absolute or relative path names to access these files or change their current
directory to the target user's directory and use file names directly.

Acyclic-Graph Directories :

1. Shared Files: Acyclic-graph directories allow files or subdirectories to be shared across multiple directories,
ensuring that changes made in one place are reflected in others.

2. Link Implementation: Shared files can be implemented using links (pointers to the original file) or by
duplicating directory entries, though the latter can lead to consistency issues.

3. Flexibility and Complexity: Acyclic-graph structures are more flexible than tree structures but introduce
complexity, especially when multiple path names refer to the same file.

4. Deletion Challenges: Deleting shared files is complex, requiring careful management of references to avoid
issues like dangling pointers. Reference counting is often used to manage when to delete a file.

5. Handling References: Systems like UNIX use reference counts to track how many links or entries point to a
file. The file is deleted only when the count reaches zero.

General Graph Directory:

1. Cycles in Graphs: Introducing links in an acyclic-graph structure can create cycles, turning the directory
system into a general graph. This introduces new complexities in traversing and managing the file system.

2. Traversal Challenges: To prevent redundant searches and infinite loops, algorithms must avoid revisiting
directories in a cycle. This is necessary for both performance and correctness.

3. File Deletion: In acyclic graphs, when the reference count reaches zero, the file can be deleted. However,
cycles can cause the reference count to remain non-zero even when a file is no longer accessible, requiring a
garbage collection process to reclaim disk space.

4. Garbage Collection: This process involves marking all accessible files, then collecting unmarked files to free
up space. However, garbage collection is time-consuming and is not commonly used for disk-based file
systems.

5. Avoiding Cycles: Preventing cycles when adding links is crucial. Algorithms to detect cycles are
computationally expensive, so simpler methods like bypassing links during traversal are often used to avoid
cycles without incurring extra overhead.

You might also like