Operating System Interface Between User and Hardware
Operating System Interface Between User and Hardware
2.
process states
Q. What is file and its types. Explain File access methods?
File’ is nothing but a logical storage unit of information
File types-
File Type Description Example File Extensions
Text Contain plain, human-readable text. Used for documents, logs, .txt, .cs
Files or configuration. v
Binary Store data in a non-readable format, meant for programs .bin, .jpg, .m
Files to interpret. p4
Source Code Contain code written in programming languages. Must .c, .java, .
Files be compiled/interpreted. py
Object Intermediate compilation files, not directly executable, linked to .o, .ob
Files form programs. j
Archive Bundle and compress multiple files together for storage or .zip, .tar, .r
Files transmission. ar
Database Store structured data for databases, allowing querying .db, .sql, .m
Files and management. db
Indexed Access
Uses an index table with pointers to file blocks.
The index helps in quick data retrieval, similar to a book’s index.
Ideal for large files with many searches and updates.
Example: A search engine or large database.
Indexed Sequential Access Method (ISAM):
Combines sequential and indexed access.
First, the index is used to locate the data, then data is accessed
sequentially.
Example: Bank records where both specific lookups and sequential scans
are needed.
A directory structure is the way files and directories (folders) are organized
within a file system of an operating system
It helps in organizing, allowing easy retrieval, storage, and access.
Types of Directory Structures:
1. Single-Level Directory:
All files are stored in a single directory. There is no hierarchy; everything
is placed at the same level.
Simple to implement and easy to understand but Difficult to manage a
large number of files; filenames must be unique.
Root Directory
├── file1
├── file2
└── file3
2. Two-Level Directory:
Each user has their own directory. Files are organized under user-specific
directories, providing a separate working space for each user.
Files are better organized as each user has their own space, and filename
conflicts are avoided between users.
Users cannot share files easily, as there is no concept of shared
directories.
Example: Used in early multi-user systems.
Root Directory
├── User1
│ ├── file1
│ └── file2
├── User2
│ ├── file1
│ └── file3
3. Tree-Structured Directory:
Organizes directories in a hierarchical tree structure, where the root
directory is at the top, and subdirectories and files branch out below it.
Allows for better organization, flexibility, and easy file searching. Files can
be grouped into directories and subdirectories.
Complex to manage as the directory tree grows.
Example: Most modern file systems like Windows, macOS, and Linux.
Root Directory
├── home
│ ├── user1
│ │ ├── documents
│ │ └── pictures
└── bin
├── file1
└── file2
4. Acyclic-Graph Directory:
Similar to a tree structure but allows directories and files to have
multiple parents. Files or directories can be shared among multiple users
or locations using links.
Enables file sharing between users or programs, without duplicating
files.
Managing links can be complex. There is a possibility of dangling pointers
if linked files are deleted.
Example: Unix and Linux systems allow symbolic (soft) and hard links.
Root Directory
├── User1
│ └── shared_file (link to /Shared/file)
├── User2
└── Shared
└── file
5. General Graph Directory:
Description: Extends the acyclic-graph structure by allowing cycles (i.e.,
a file or directory can link back to an earlier directory).
Advantages: Flexible and allows for complex relationships between
directories.
Disadvantages: Can lead to issues like infinite loops during traversal if
cycles are not managed.
Example: Rarely used due to the complexity in managing cycles but can
be implemented with symbolic links in Unix/Linux.
Root Directory
├── dir1
│ └── dir2
│ └── dir1 (link back to /dir1)
6. Shared (Multiple-Level) Directory:
Description: In this structure, files and directories are organized in
multiple levels, with shared directories available to all users.
Advantages: Combines the benefits of multiple-level directory structures
with shared access to files.
Disadvantages: Managing file permissions and access control can
become complex.
Example: Common in enterprise or networked systems where multiple
users need to access shared resources.
2. Linked Allocation: Files are stored as a linked list of blocks scattered across
the disk. Each block contains data and a pointer to the next block in the file.
The last block has a null pointer indicating the end of the file.
No external fragmentation: Any free block can be used.
Dynamic file size: Files can grow dynamically by adding new blocks.
Disadvantages:
Slow access: pointers, making access slower compared to contiguous
allocation.
Space overhead: Each block needs extra space to store the pointer.
Reliability: If a pointer is corrupted, the entire file could be lost.
Example: Used in Unix-based systems for managing files.
3. Indexed Allocation: An index block is created for each file, and this index
contains pointers to all the blocks that make up the file.
The index block allows random access to file data.
o Direct access: Provides fast random access to file blocks.
o No external fragmentation: Any free block can be used.
Disadvantages:
o Overhead: Requires extra space for index blocks.
o Large files: For very large files, the index can become large,
requiring additional levels of indexing (multi-level indexing).
Example: modern operating systems like Unix/Linux with i-nodes.
Q. EXPLAIN Layers design in File System
A file system in an operating system is organized into multiple layers, each
responsible for different aspects of file management and storage.