0% found this document useful (0 votes)
9 views13 pages

File Attributes and Allocation Methods

The document outlines key concepts related to file attributes, directory structures, file allocation methods, and access methods. It discusses the internal structure of files, disk access time computation, and various directory structures, including their pros and cons. Additionally, it covers free space management techniques, goals of protection in operating systems, and the principle of least privilege.
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)
9 views13 pages

File Attributes and Allocation Methods

The document outlines key concepts related to file attributes, directory structures, file allocation methods, and access methods. It discusses the internal structure of files, disk access time computation, and various directory structures, including their pros and cons. Additionally, it covers free space management techniques, goals of protection in operating systems, and the principle of least privilege.
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

Unit 5

1. List the File Attributes


File Attributes:

• Name: The name of the file (with extension).


• Identifier: Unique ID to distinguish the file (e.g., inode number).
• Type: File type (text, executable, binary, etc.).
• Location: Pointer(s) to the file’s location on storage.
• Size: File size in bytes.
• Protection: Access permissions (read, write, execute).
• Timestamps: Creation, modification, and last access times.

2. What is a directory structure?


• A method to organize and store files in a file system, usually in a
hierarchical manner.
• Facilitates efficient file management, retrieval, and navigation.
• Files are grouped into directories (folders), which may contain sub-
directories.
• Common types include tree-structured, acyclic-graph, and general graph
structures, offering different levels of flexibility and sharing.

3. Explain the file allocation methods with diagrams with its pros
and cons..
File Allocation Methods:

• Contiguous Allocation :
• Description: Each file is stored in consecutive blocks on the disk. The OS
keeps track of the starting block and length of the file.

• Advantages:
o Very fast sequential read/write since blocks are contiguous.
o Efficient direct or random access.
o Simple to implement and manage.
• Disadvantages:
o External fragmentation occurs.
o File growth is difficult; extending a file may require moving or
defragmentation.
o Not suitable for dynamic file sizes.
• Linked Allocation :
• Description: Files are stored as linked lists of disk blocks, where each block
contains a pointer to the next block.
• Advantages:
o No external fragmentation.
o Files can grow dynamically by adding new blocks.
o Efficient for sequential access.
• Disadvantages:
o Poor random access performance, as traversal from the start is
required.
o Overhead of storing pointers in each block.
o Risk of pointer loss or damage, affecting file integrity.
• Indexed Allocation :
• Description: Uses an index block that contains pointers to all blocks of a
file. The index is stored separately from data blocks.

• Advantages:
o Supports efficient direct access.
o Prevents file fragmentation.
o Suitable for large files; file size can be easily extended.
• Disadvantages:
o Overhead of storing the index block.
o Inefficient for small files if large index blocks are allocated.
o Potential internal fragmentation within the index structure

4. Compare different file access methods (sequential and


indexed).
Aspect Sequential Access Indexed Access
Sequential, ordered
Access Type Direct (random) access
reading/writing
Efficiency for Large Good when data is processed in Very efficient for large and randomly
Files order accessed files
Ease of Slightly complex due to index
Simple
Implementation management
Overhead Low Higher (due to index structures)
Applications with frequent random data
Suitable for Batch processing, streaming data
access
Limited (must process data
Flexibility High (can jump directly to any record)
sequentially)

5. Explain the internal structure of a file and how it affects


storage efficiency.
The internal structure of a file refers to the way data is physically organized and
stored on the disk.
A file is typically divided into fixed-size or variable-size blocks called physical
blocks, and the way these blocks are managed impacts both storage efficiency and
access performance.

Key Points:

1. Organization in Blocks:
a. Data is stored in blocks on disk; a block may contain one or more
records.
b. The block size can vary depending on the file system or the type of
data.
2. Internal Fragmentation:
a. Wasted space occurs when a block is not fully utilized by the file.
b. Larger block sizes increase internal fragmentation, as small files may
leave significant unused space.
3. Storage Schemes:
a. Sequential storage: Blocks are stored consecutively. Efficient for
sequential access but can cause fragmentation.
b. Indexed storage: An index points to the blocks of a file. Reduces
fragmentation and allows random access but adds overhead for the
index.
4. Effect on Storage Efficiency:
a. Smaller blocks improve space utilization but may increase overhead
for managing many blocks.
b. Larger blocks reduce management overhead but can lead to wasted
space within partially filled blocks.
5. Effect on Access Performance:
a. Sequential storage allows fast sequential reads/writes.
b. Indexed or linked storage allows random access to records efficiently
but may increase access time due to additional lookups.

6. How do you compute disk access time? Explain with a neat


diagram for disk structure.

A disk consists of several components:


1. Platters: Circular disks coated with magnetic material to store data.
2. Tracks: Concentric circles on each platter where data is recorded.
3. Sectors: Each track is divided into sectors, the smallest addressable unit of
storage.
4. Cylinders: Set of tracks at the same radius across all platters.
5. Read/Write Head: Moves radially to access different tracks.
Disk Access Time

The total time to access data on a disk is composed of three main components:

1. Seek Time (Ts):


a. Time taken for the disk arm to move the read/write head to the track
containing the desired data.
2. Rotational Latency (Tr):
a. Time taken for the desired sector to rotate under the read/write head.
b. Average rotational latency = 1 / (2 × rotational speed)
3. Transfer Time (Tt):
a. Time to actually transfer the data once the head is positioned
correctly.
b. Depends on number of bytes to transfer and disk rotation speed.

Disk Access Time Formula:


Disk Access Time = Seek Time + Rotational Latency + Transfer Time
T_access = Ts + Tr + Tt

7. Compare different directory structures with suitable examples.

1. Single-Level Directory :
a. Description: All files are stored in a single directory.
b. Advantages: Easy to implement; simple file operations; fast
search for small directories.
c. Disadvantages: Name collisions if multiple users exist; searching
becomes slower for large directories; cannot group similar files.

2. Two-Level Directory :
a. Description: Each user has a separate directory (User File
Directory – UFD). The system has a Master File Directory (MFD)
pointing to all UFDs.
b. Advantages: Users can have files with the same name; easier
search using pathname; supports multiple users.
c. Disadvantages: Users cannot share files easily; cannot group
similar files across users; not very scalable.

3. Tree-Structured Directory :
a. Description: Hierarchical directories; users/processes have a
current directory; supports absolute and relative paths.
b. Advantages: Scalable; reduces name collisions; easy searching
with full or relative paths.
c. Disadvantages: Accessing files may require navigating multiple
directories; file sharing is not supported; some files may not fit
well in the hierarchy.

4. Acyclic-Graph Directory :
a. Description: Directories can share files using hard links (same
file, multiple entries) or symbolic/soft links (pointers to files).
b. Advantages: File sharing is possible; multiple paths make
searching easier.
c. Disadvantages: Deleting files can create problems; soft links can
become dangling; hard links require deleting all references to
remove the file.

5. General Graph Directory :


a. Description: Allows cycles in the directory graph. More flexible
than tree or acyclic-graph structures.
b. Advantages: Cycles allowed; very flexible structure; supports
complex sharing scenarios.
c. Disadvantages: Costly to maintain; search algorithms may need to
avoid infinite loops; requires garbage collection to manage
disconnected or orphaned files.

8. What are the commonly used file operations? Give examples.


Operation Description Example
Create a file Allocate space and add to directory Creating a new document or spreadsheet
Write to a file Store data in an open file Saving new content into [Link]
Read from a file Access data stored in a file Opening and viewing [Link]
Reposition within Navigating to the 50th byte in a video file
Move file pointer to a specific location
a file for editing
Delete a file Remove file and free its space Deleting an outdated backup file
Shorten file size by removing data Truncating a log file to keep only latest
Truncate a file
from the end entries

9. Consider a logical address space of 32 pages of 2048 words


mapped into memory of 128 frames.
Each entry in the page table takes 4 bytes of memory.
a. How many bits are there in the logical address?
b. How many bits are there in physical address?
c. Find the size of the page table.
d. Find the size of RAM (user space)
Given:

• Logical address space: 32 pages


• Page size: 2048 words
• Physical memory: 128 frames
• Page table entry: 4 bytes

a. Number of bits in the logical address

Logical address consists of page number and page offset.

1. Page number bits:


a. Number of pages = 32 → needs log2(32) = 5 bits
2. Page offset bits:
a. Page size = 2048 words → needs log2(2048) = 11 bits

Logical address bits = 5 + 11 = 16 bits

b. Number of bits in the physical address

Physical address consists of frame number and page offset.


1. Frame number bits:
a. Number of frames = 128 → log2(128) = 7 bits
2. Page offset bits:
a. Same as page size → 11 bits

Physical address bits = 7 + 11 = 18 bits

c. Size of the page table

• Page table has one entry per page


• Number of pages = 32
• Size of each entry = 4 bytes

Page table size = 32 × 4 = 128 bytes

d. Size of RAM (user space)

• Number of frames = 128


• Frame size = Page size = 2048 words

RAM size = 128 × 2048 = 262,144 words

[Link] different directory structures in detail with pros and


cons of each method.
Note : Answer given in [Link] 7

[Link] in detail about free space management.


Free-space management is the technique used by an operating system to keep track
of and allocate free blocks on a disk. There are several methods:

1. Bit Vector (Bitmap)


a. Each bit represents a disk block: 1 if free, 0 if allocated.
b. Fast for finding contiguous blocks.
c. Disadvantage: Large disks require significant memory to store the
bitmap (e.g., a 40GB disk may need over 5MB for the bitmap).
2. Linked List
a. Free blocks are kept in a linked list.
b. Easy to add or remove single blocks from the list.
c. Finding contiguous blocks is not efficient, but usually not needed
frequently.
d. FAT (File Allocation Table) is an example of this approach.

3. Grouping
a. Variation of linked list: a block holds multiple addresses of free
blocks and a pointer to the next block of free addresses.
b. Reduces overhead compared to a simple linked list.

4. Counting
a. Tracks groups of contiguous free blocks by storing the starting
address and the count of blocks.
b. Efficient when multiple contiguous free blocks exist; saves space
similar to compression techniques.

[Link] the following with relevant diagrams:

a) Single level directory structure


b) Two-level directory structure.

Note : Answer given in [Link] 7

[Link] Goals of Protection.


Goals of Protection

Protection in an operating system ensures that resources such as files, memory, and
devices are used only in authorized ways.
The main goals of protection in the context of file systems and file attributes are:

1. Controlled Access
a. Only authorized users or processes can access a file or perform
specific operations (read, write, execute).
2. Integrity
a. Ensure that data is not accidentally or maliciously modified by
unauthorized users.
3. Privacy (Confidentiality)
a. Protect sensitive information in files from being accessed by
unauthorized users.
4. Accountability
a. Keep track of who accessed or modified files, often using user IDs
and access logs.
5. Flexibility
a. Allow different levels of access for different users or groups, such as
owner, group, and others.
6. Minimize Errors and Misuse
a. Prevent accidental deletion, overwriting, or misuse of files.
14. Explain principle of least privilege.
The Principle of Least Privilege is a key security concept in operating systems
and file systems.

It states that every user, program, or process should be granted only the
minimum privileges necessary to perform its required tasks, and no more.

Key Points:
1. Minimal Access:
a. Users or processes get only the permissions they need to complete a
job, reducing potential damage from accidents or malicious actions.
2. Limits Security Risks:
a. If an account or process is compromised, the attacker can access only
a limited set of resources, minimizing potential harm.
3. Prevents Unauthorized Actions:
a. Helps prevent users or programs from accidentally or intentionally
modifying files, deleting data, or accessing sensitive information
beyond their scope.
4. Dynamic Application:
a. Privileges can be adjusted over time as tasks change, ensuring that no
unnecessary rights remain assigned.

You might also like