0% found this document useful (0 votes)
11 views14 pages

Chapter 1 (OS)

The document provides an overview of operating systems, detailing the architecture of monolithic kernels, various services, and primary functions of operating systems. It also discusses multitasking vs. multi-threading, buffer cache roles in Unix, inode management, and file allocation strategies. Additionally, it covers standard input/output streams in Unix, including redirection techniques and their benefits for system monitoring and troubleshooting.

Uploaded by

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

Chapter 1 (OS)

The document provides an overview of operating systems, detailing the architecture of monolithic kernels, various services, and primary functions of operating systems. It also discusses multitasking vs. multi-threading, buffer cache roles in Unix, inode management, and file allocation strategies. Additionally, it covers standard input/output streams in Unix, including redirection techniques and their benefits for system monitoring and troubleshooting.

Uploaded by

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

Chapter 1: Introduction to Operating System (4 Marks)

1. Why do general-purpose operating systems use monolithic kernel architecture?

General-purpose operating systems use monolithic kernels because:

 Efficiency: All parts run in one place, making system calls fast.

 Performance: Tightly connected parts work faster together.

 Feature-Rich: It has built-in features like drivers and file systems.

 Simplicity: Easier to manage as everything is in one system.

2. Explain various services provided by the operating system.

 Process Management: Manages running programs and multitasking.

 Memory Management: Allocates and tracks system memory.

 File System Management: Organizes and manages data storage.

 Device Management: Handles input/output devices like printers and disks.

 Security and Access Control: Protects data and resources.

 Networking: Manages data exchange over networks.

3. Explain the primary functions of an operating system.

 Resource Management: Allocates CPU, memory, and devices to tasks.

 User Interface: Provides a way for users to interact (e.g., GUI, CLI).

 File Management: Manages files and directories.

 Security: Prevents unauthorized access and ensures data integrity.

4.Differentiate multitasking and multi-threaded operating systems.


Multitasking Multi-threaded
Runs multiple processes. Runs multiple threads in a single process.
Multiple tabs in Chrome.
Running Word and Chrome
Lower due to shared memory space.
Higher due to process management.
Java Virtual Machine, modern web browsers.
Windows, Linux
5. Differentiate multi-threaded and multi-processing operating systems.

Multi-threaded Multi-processing

Uses threads in one process. Uses multiple processes.

Threads share the same memory space. Each process has its own memory space.

Efficient for lightweight tasks. Better for heavy, independent tasks.

Java programs. High-performance computing systems.

6. What are the main differences between monolithic and microkernels?

Monolithic Kernel Microkernel

All functions in one kernel. Only essential functions in kernel.

Faster, less overhead. More stable, modular.

Harder to debug. Easier to maintain.

Linux, Unix. Minix, QNX.

7. List and explain features of the Unix operating system.

 Multitasking: Runs multiple programs simultaneously.

 Multiuser: Supports multiple users at the same time.

 Portability: Runs on different hardware platforms.

 Security: Provides user authentication and file permissions.

 Shell Interface: Offers a command-line interface.

8. Explain the Unix operating system kernel structure.

Ans ch photo patavte.

9. Explain concepts of redirection with example.

Redirection allows sending output to a file or taking input from a file instead of the terminal.

Algorithm : input redirection

if(/* redirect input*/)


{

Fd=create(newfile, fmask);

Close(stdin);

dup(fd);

close(fd);

/*stdin is now redirected*/

Example:

sort < names.txt

(Takes input from names.txt for sorting instead of typing manually.)

Algorithm : output redirection

if(/* redirect output*/)

Fd=create(newfile, fmask);

Close(stdout);

dup(fd);

close(fd);

/*stdout is now redirected*/

Example:

ls > filelist.txt

(Saves the list of files into filelist.txt instead of showing on screen.)

File Subsystem (4 Marks)

1.Write and Explain brelease() Algorithm


2. What is the Role of the Buffer Cache in the Unix Operating System?

The buffer cache in Unix serves as a temporary storage area for disk blocks to:

 Reduce Disk I/O: Frequently accessed data is cached in memory, reducing repetitive disk
reads and writes.

 Improve Performance: Accessing data from memory is faster than reading from the disk.

 Data Consistency: Maintains synchronization between disk and memory.

3. Write and Explain bwrite() Algorithm


4. Explain All Scenarios for Retrieval of Buffer

1. Block is found on its hash queue and its buffer is free.


2. Block could not be found on the hash queue, so a buffer from
the free list is allocated.
3. Block could not be found on the hash queue, and when
allocating a buffer from free list, a buffer marked "delayed
write" is allocated. Then the kernel must write the "delayed
write" buffer to disk and allocate another buffer.
4. Block could not be found on the hash queue and the free list
of buffers is empty.
5. Block was found on the hash queue, but its buffer is currently
busy.

5. List of Advantages and Limitations of Buffer Cache

Advantages:

 Reduces disk I/O operations.

 Improves file system performance.

 Allows batching of write operations, minimizing disk wear.

Limitations:

 Uses memory that could be allocated to other processes.

 Risk of data loss if dirty buffers are not written back before a crash.

 May hold outdated data if not synchronized correctly

6. How does Unix convert a le path into an inode?

Unix resolves a le path into an inode using these steps:

 Parse the Path: Split the path into components (e.g., /home/user/file).
 Traverse Directories: Start from the root or current directory, navigating each component.
 Directory Lookup: For each directory, locate the next component’s inode.
 Inode Resolution: Retrieve the inode for the final component.

7. Explain the Structure of the Buffer Pool

The buffer pool is a collection of buffers used for caching disk blocks. It includes:

 Buffer Headers: Store metadata such as block number, device ID, and status flags.

 Data Blocks: Hold the actual content of disk blocks.

 Free List: Tracks buffers available for use.


8. List and Explain the Contents of the Buffer Header

The buffer header contains:

 Device ID: Identifies the disk device associated with the buffer.

 Block Number: Specifies the disk block being cached.

 Status Flags: Indicate buffer state (e.g., locked, delayed write).

 Pointers: Link the buffer to the free list or other data structures.

9. What is the Role of the Buffer Cache in Unix? How Does It Improve File System Performance?

Role: The buffer cache temporarily stores disk blocks in memory to speed up data access and reduce
the frequency of disk I/O operations.

Performance Improvements:

 Faster Access: Serves requests from memory rather than disk.

 Reduced Latency: Minimizes delays caused by slow disk operations.

 Efficient Writes: Combines multiple writes into fewer disk operations, reducing overhead.

 Optimized Reads: Frequently accessed blocks remain in memory, improving read


performance.

Application-Oriented Questions (4 Marks)


1.The size of each block on the hard disk is 1 KB, and the size of each inode is 128 bytes. Calculate
how many inodes can fit in a single block. Additionally, if you want to create 32 files, determine
the number of blocks required to store the inodes for all these files.

◦ Inodes per Block: Each block can hold 1024 / 128 = 8 inodes.

◦ Blocks Required for 32 Files: 32 / 8 = 4 blocks are needed to store the inodes.

Chatgpt Explanation :

 Given:

o Block size = 1 KB = 1024 bytes

o Inode size = 128 bytes

 Calculation:

o Inodes per block = Block size / Inode size

Inodes per block= 1024/128 = 8

o Blocks required for 32 files = ⌈32/8] = 4


Answer:

 Inodes per block: 8

 Blocks required: 4

2. In a file system, each inode occupies 128 bytes, and the block size is 2 KB. Calculate the number
of inodes that can be stored in a single block. If a directory contains 100 files, determine how many
blocks are required to store the inodes for these files.

◦ Inodes per Block: Each block can hold 2048 / 128 = 16 inodes.

◦ Blocks Required for 100 Files: 100 / 16 = 6.25, rounded up to 7 blocks.

 Given:

o Block size = 2 KB = 2048 bytes

o Inode size = 128 bytes

 Calculation:

o Inodes per block = 2048/128=16

o Blocks required for 100 files = ⌈100/16⌉ = 7

Answer:

 Inodes per block: 16

 Blocks required: 7

3. The size of each block on the hard disk is 1 KB, and the size of each inode is 128 bytes. Start
address of Inode block is 3. In which block inode 15 will be found?

◦ Inodes per Block: 8 inodes per block.

◦ Block Calculation: Inode 15 is in block (15 / 8) = 1.875, rounded up to block 2.

Adding the start address, the inode is in block 3 + 2 = Block 5.

 Given:

o Block size = 1 KB = 1024 bytes

o Inode size = 128 bytes

o Start address of inode block = Block 3

 Calculation:

o Inodes per block = 1024/128=8


o Inode 15 is in ⌈15/8⌉=2nd block

o Starting block is Block 3. So, inode 15 is in Block 3+1=4.

Answer: Inode 15 is in Block 4.

4.A regular le is 25 KB. Analyze how the 13-member array handles this allocation using direct,
single-indirect, and double-indirect pointers. Provide a detailed breakdown of the allocation
process. (Block size = 1 KB)

◦ Direct Pointers: 10 blocks.

◦ Single-Indirect Pointer: Points to a block holding 1 KB worth of pointers; it references the remaining
15 - 10 = 5 blocks.

◦ Double-Indirect Pointer: Not used for this file size.

5. If a le is 15 KB in size and the block size is 1 KB, determine how many blocks are allocated to
direct pointers and how many are allocated through single-indirect pointers. Explain your
reasoning.

◦ Direct Pointers: 10 blocks.

◦ Single-Indirect Pointer: Points to a block that references the remaining 15 - 10 = 5 blocks.

6. Explain the role of single-indirect pointers when storing a le of 20 KB using a 13- member array
in the inode with a block size of 1 KB. How many blocks are utilized?

◦ Direct Pointers: 10 blocks.

◦ Single-Indirect Pointer: Points to a block that references the remaining 20 - 10 = 10 blocks.

◦ Total Blocks: 10 (direct) + 1 (single-indirect) + 10 (referenced) = 21 blocks.

7. A file system uses a free block list to allocate disk blocks. Describe how the alloc algorithm
assigns blocks to a new file requiring 5 blocks. If the free block list initially contains [5, 12, 20, 25,
30, 32, 47], show the final state of the free block list after allocation.

◦ Allocation: The algorithm assigns the first 5 blocks: [5, 12, 20, 25, 30].

◦ Final Free Block List: [32, 47].

 Given:

o Free block list: [5, 12, 20, 25, 30, 32, 47]

o Required blocks = 5

Allocation Steps:

1. Assign the first 5 blocks: [5, 12, 20, 25, 30].


2. Update the free block list: [32, 47].

Answer: Final free block list: [32, 47].

8. A file is deleted, and the free algorithm is used to reclaim its blocks. The deleted le occupied disk
blocks [10, 11, 15, 20]. If the free block list initially contains [5, 6, 8], demonstrate the state of the
list after the blocks are reclaimed.

◦ Updated Free Block List: [10, 11, 15, 20, 5, 6, 8].

 Given:

o Deleted file blocks: [10, 11, 15, 20]

o Initial free block list: [5, 6, 8]

Reclamation:

1. Add the deleted blocks to the free list: [10, 11, 15, 20].

2. Merge the lists: [5, 6, 8, 10, 11, 15, 20].

Answer: Final free block list: [5, 6, 8, 10, 11, 15, 20].

9. A file system uses an indexed free block structure. If the free block list has [100, 105, 110, 120,
130], explain how the alloc algorithm assigns blocks to a new file of size 3 KB (block size = 1 KB).
Show the updated free block list.

◦ Allocation: The algorithm assigns [100, 105, 110].

◦ Updated Free Block List: [120, 130].

 Given:

o Free block list: [100, 105, 110, 120, 130]

o File size = 3 KB

o Block size = 1 KB

Allocation Steps:

1. Assign the first 3 blocks: [100, 105, 110].

2. Update the free block list: [120, 130].

Answer: Final free block list: [120, 130].

Command or shell script or C Code writing (8 marks)


1.Explain the three standard input/output (I/O) streams in Unix systems. Briefly describe the purpose
of each stream. Write a shell command to:
a.Redirect the standard output of a find command to a file named output.log.

b.Redirect any errors (e.g., "Permission denied") to a file named errors.log.

c.Discuss how separating output and error logs can streamline system monitoring.

1. Three Standard Input/Output Streams in Unix Systems

1. Standard Input (stdin): Accepts input from the user or another program (default is the
keyboard).

2. Standard Output (stdout): Outputs normal operation results (default is the terminal).

3. Standard Error (stderr): Displays error messages (default is the terminal).

Commands:

a. Redirect standard output of the find command to a file:

find / -name "*.txt" > output.log

b. Redirect errors to a file:

find / -name "*.txt" 2> errors.log

c. Discuss: Separating outputs and errors improves clarity and allows monitoring each aspect
independently without overwriting crucial data.

2.Describe the role of standard input, output, and error streams in Unix. Write a series of commands
to:

1. Redirect input for wc command from a file named data.txt.

2. Redirect output to result.log.

3. Append errors to an existing file named error.log.

4. Analyze the benefit of appending errors instead of overwriting them.

2. Redirecting Input, Output, and Errors

a. Redirect input for wc from data.txt:

wc < data.txt

b. Redirect output to result.log:

wc < data.txt > result.log

c. Append errors to error.log:

wc < data.txt 2>> error.log

d. Benefit of appending errors: Ensures that past errors are not lost and facilitates tracking issues
over time.
3.Explain the three standard input/output (I/O) streams in Unix systems. Briefly describe the purpose
of each stream. Write a command to:

1. Redirect the output of the grep command to a file named matches.txt.

2. Redirect errors to the same file.

3. Explain how this redirection can simplify troubleshooting a script searching for patterns in
multiple files.

3. Redirection for Troubleshooting

Commands:

a. Redirect grep output to matches.txt:

grep "pattern" *.txt > matches.txt

b. Redirect errors to the same file:

grep "pattern" *.txt > matches.txt 2>&1

c. Explanation: Combining output and errors in one file helps pinpoint issues during
pattern searching, especially across multiple files.

4.Differentiate between hardware interrupts and software exceptions with examples of how each is
triggered in a system.

 Hardware Interrupts: Triggered by hardware devices (e.g., a keyboard press, disk I/O).

 Software Exceptions: Triggered by program errors or instructions (e.g., division by zero,


system calls).

5.Discuss the concept of interruptions and their types maskable and non-maskable interrupts and
high-priority and low-priority interrupts. Provide an example of each type Explain how they differ in
their handling by the processor

 Maskable Interrupts: Can be disabled or ignored (e.g., timer interrupt).

 Non-Maskable Interrupts (NMI): Cannot be ignored (e.g., power failure).

 High-Priority Interrupts: Handled immediately (e.g., NMI).

 Low-Priority Interrupts: Handled when higher-priority interrupts are not pending (e.g., periodic
timer).

6.Analyze the concept of processor execution level in handling interrupts. Comment on the following
scenarios:

 When the processor’s execution level is always high.


o Analyze how the processor handles interrupts in this scenario.

o Discuss the potential effects on interrupt servicing and overall system performance.

o What could be the implications for lower-priority interrupts?

 When the processor’s execution level is always low.

o Analyze the behavior of the system when the processor is at a low execution level
during interrupt handling.

o Discuss how interrupts are prioritized and the possible delays in handling higher-
priority interrupts.

o What impact could this have on real-time system requirements and interrupt
latency?

 High Execution Level:

 All lower-priority interrupts are delayed, reducing system responsiveness.

 Critical tasks are executed uninterrupted.

 Low Execution Level:

 System prioritizes all interrupts but may delay critical high-priority tasks, causing latency in
real-time systems.

7.Pipelines allow for chaining commands to perform complex tasks efficiently. Construct a pipeline
to:

 List files in the current directory.

 Filter files larger than 1MB.

 Count the number of such files.

 Save the result to large_files_count.txt.

 Justify the use of each command in the pipeline.

7. Pipeline for Filtering Large Files

ls -lh | awk '$5 ~ /[0-9]*M/' | wc -l > large_files_count.txt

Explanation:

 ls -lh: Lists files with human-readable sizes.

 awk '$5 ~ /[0-9]*M/': Filters files larger than 1 MB.

 wc -l: Counts matching files.

 > large_files_count.txt: Saves the result.

8.Construct a pipeline to:


 List all files in the /var/log directory.

 Filter files that were modified in the last 7 days.

 Sort them by modification time.

 Display the top 5 most recently modified files.

 Save the result to recent_logs.txt.

 Justify the use of each command in the pipeline and explain how the pipeline achieves the
task.

. Pipeline for Recent Logs

find /var/log -type f -mtime -7 -exec ls -lt {} + | head -n 5 > recent_logs.txt

Explanation:

 find /var/log -type f -mtime -7: Finds files modified in the last 7 days.

 ls -lt: Sorts files by modification time.

 head -n 5: Displays the 5 most recent files.

 > recent_logs.txt: Saves the result.

9.Construct a pipeline to:

• List all files in the /home/user/documents directory.

• Find files that contain the word "confidential" in their names.

• Sort the filtered files alphabetically.

• Display the total number of matching files.

• Save the result to confidential_files.txt.

9. Pipeline for Confidential Files

ls /home/user/documents | grep "confidential" | sort | tee confidential_files.txt | wc -l

Explanation:

 ls /home/user/documents: Lists files in the directory.

 grep "confidential": Filters files containing "confidential".

 sort: Sorts results alphabetically.

 tee confidential_files.txt: Saves filtered results to a file while displaying them.

 wc -l: Counts matching files.

10.Discuss the advantages of using a pipeline for this task and the functionality of each command.
 Streamlined command chaining avoids intermediate files.

 Results and count are generated simultaneously for efficiency.

You might also like