0% found this document useful (0 votes)
22 views

Answer Key -OS

The document provides answer keys for an Operating Systems examination, detailing various topics such as resource allocation, system calls, CPU scheduling algorithms, and file system management. It includes explanations of different operating system structures, virtualization concepts, and synchronization problems like the Producer-Consumer problem. Additionally, it covers disk scheduling algorithms and the Banker's algorithm for deadlock avoidance.

Uploaded by

abernakumari87
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)
22 views

Answer Key -OS

The document provides answer keys for an Operating Systems examination, detailing various topics such as resource allocation, system calls, CPU scheduling algorithms, and file system management. It includes explanations of different operating system structures, virtualization concepts, and synchronization problems like the Producer-Consumer problem. Additionally, it covers disk scheduling algorithms and the Banker's algorithm for deadlock avoidance.

Uploaded by

abernakumari87
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/ 13

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

B.E/B.TECH.END SEMESTER THEORY EXAMINATIONS,APRIL/MAY 2025.


AL3452 & OPERATING SYSTEMS
(REGULATIONS 2021)
ANSWER KEYS
PART A 10 X 2 =20 MARKS
1. Why is the operating system viewed as a resource allocator and control program?
The operating system (OS) acts as:
 Resource Allocator: Manages and allocates hardware and software resources (CPU, memory, I/O
devices) among users and applications.
 Control Program: Controls the execution of programs to prevent errors and improper use of the
system.
2. State any two differences between monolithic and microkernel operating system structures.

Feature Monolithic Kernel Microkernel

Structure All OS services run in kernel mode Only essential services in kernel mode

Stability Less stable (bug in one module may crash system) More stable (services run in user space)

3. When a process creates a new process using the fork() operation, which of the following state is
shared between the parent process and the child process?
Shared Memory Segment
By default, the child gets a copy of the parent’s memory. However, shared memory segments (if explicitly
created) are shared between both.
4. List the situations that may require the scheduler to make scheduling decisions.
 When a process switches from running to waiting.
 When a process terminates.
 When a process is created.
 When a process switches from waiting to ready.
5. List any two differences between a physical address and a logical address.

Feature Logical Address Physical Address

Definition Generated by CPU (virtual) Address in memory unit (real)

Accessibility Cannot access directly Can be accessed directly


6. A system has a logical address space of 7 bits and a physical address space of 6 bits. If the page
size is 8 words/bytes, calculate the number of pages in the logical address space and the number of
frames in the physical address space.
 Logical address space = 27=1282^7 = 12827=128 bytes
Page size = 8 bytes
→ Number of pages = 128/8=16128 / 8 = 16128/8=16
 Physical address space = 26=642^6 = 6426=64 bytes
→ Number of frames = 64/8=864 / 8 = 864/8=8
 Pages = 16
 Frames = 8
7. Write a short note on file system mounting.
Mounting is the process of making a file system accessible at a certain point in the directory tree.
When a device is mounted, its file system is attached to a directory (mount point) and becomes accessible
to the user.
8. What is the role of Application I/O Interface in an OS?
The Application I/O Interface provides a consistent interface for user-level applications to perform
I/O operations without needing to understand device-specific details. It abstracts hardware complexity.
9. Define paravirtualization.
Paravirtualization is a virtualization technique where the guest OS is modified to interact with the
hypervisor using hypercalls, resulting in better performance than full virtualization.
10. Define hypervisor. What are the two components of hypervisor?
A hypervisor is a software layer that allows multiple operating systems (virtual machines) to run on
a single physical machine.
Two Components:
1. Virtual Machine Monitor (VMM) – Manages virtual machines.
2. Virtual Hardware Manager – Emulates virtual hardware resources.

PART B 5 X 13 = 65 MARKS
11. a) (i) What are system calls? State and explain the types of system calls.[5 Marks]
Definition:
A system call is a programmatic way in which a user program requests a service from the operating
system's kernel. These services may include hardware-related services (I/O), file management, process
control, and more.
Types of System Calls:
1. Process Control:
o Create, terminate, load, execute processes.
o E.g., fork(), exit(), wait()
2. File Management:
o Create, open, read, write, close files.
o E.g., open(), read(), write(), close()
3. Device Management:
o Request/release device, read/write to device.
o E.g., ioctl(), read(), write()
4. Information Maintenance:
o Get/set system data, time, process attributes.
o E.g., getpid(), alarm()
5. Communication:
o Message passing between processes (IPC).
o E.g., pipe(), shmget(), msgsnd()
11. a) (ii) Explain the various structures of an operating system.[8 Marks]
1. Monolithic Architecture:
 OS is a large, single executable.
 All services (I/O, file management, memory) are in the kernel.
 Example: MS-DOS
Pros: Fast performance
Cons: Hard to debug and maintain
2. Layered Architecture:
 OS is divided into layers. Each layer performs specific functions and interacts only with the layer
below.
 Example: THE operating system
Pros: Modularity, ease of debugging
Cons: Overhead due to multiple layers
3. Microkernel Architecture:
 Only essential functions (e.g., memory management, IPC) run in kernel mode.
 Other services (device drivers, file systems) run in user mode.
Example: QNX, Minix
Pros: Stability and security
Cons: May reduce performance due to increased user-kernel communication
4. Modular Architecture:
 Kernel has loadable modules (like plug-ins) for extending features.
 Example: Linux Kernel
Pros: Flexibility and easy customization
Cons: Slight performance overhead
5. Hybrid Architecture:
 Combination of monolithic and microkernel designs.
 Example: Windows NT, macOS
Pros: Performance + Modularity
Cons: Increased complexity
(OR)
11. b) A company is looking to upgrade its current computer system... recommend an architecture
that would enhance performance and scalability.[13 Marks]
Recommended Architecture:
1. CPU Architecture:
 Use multi-core processors for parallel execution.
 Choose 64-bit architecture for large address space.
 Support for virtualization (e.g., Intel VT-x or AMD-V).
2. Memory:
 Increase RAM capacity (e.g., 16 GB or more for multitasking).
 Use DDR4/DDR5 for faster access.
 Implement virtual memory and memory paging.
3. Storage:
 Upgrade to NVMe SSDs for fast read/write.
 Use RAID (Redundant Array of Independent Disks) for reliability and performance.
4. Input/Output Devices:
 High-speed I/O buses (USB 3.0, Thunderbolt).
 Network Interface Cards (NICs) for faster communication.
 Use DMA (Direct Memory Access) to reduce CPU load during I/O.
5. Scalability Considerations:
 Modular system components for future upgrades.
 Support for cloud integration and virtual machines.
 Use of server-grade motherboards for expandability.
12 a) CPU Scheduling Algorithms
Given processes:

Process Burst Time Arrival Time Priority

P1 (Email) 0 10 4

P2 (Web Browsing) 1 5 3

P3 (Video Streaming) 3 2 1

P4 (Database Querying) 4 3 2

i) Shortest Job First (SJF - Non-Preemptive)


Order: P3 → P2 → P4 (P1 has 0 burst time, execute last or ignore)
Gantt Chart:
P3 | P2 | P4
Start Time = 2, 5, 6
ATAT = (Finish - Arrival)
ii) Round Robin (RR), tq = 3 ms
Queue (arrival): P3(2), P4(3), P2(5), P1(10)
Simulate RR with time quantum 3
 P3 (3) → Done
 P4 (4) → 3,1
 P2 (1) → Done
 P4 → 1
 P1(0) → Ignore
iii) Preemptive Priority Scheduling
Lower number = higher priority
Order: P3 (1) → P4 (2) → P2 (3) → P1 (4)
Gantt chart as per arrival and preemption
Metrics to compute:
 Waiting Time (WT) = Turnaround - Burst
 Turnaround Time (TAT) = Finish – Arrival
(OR)
12 b) Producer-Consumer Problem with Semaphores
 A classic synchronization problem.
 Use two semaphores:
o empty – counts empty slots.
o full – counts filled slots.
 Use mutex for critical section.
Pseudocode:
semaphore mutex = 1;
semaphore full = 0;
semaphore empty = n;
Producer() {
wait(empty);
wait(mutex);
// add item to buffer
signal(mutex);
signal(full);
}
Consumer() {
wait(full);
wait(mutex);
// remove item from buffer
signal(mutex);
signal(empty);
}
13 a)
(i) Demand Paging
 Pages are loaded into memory on demand.
 Invalid page → page fault → load from disk.

(ii) Paging Address Translation


 Logical Address = (Page Number, Offset)
 Use page table → get Frame Number
 Physical Address = (Frame Number, Offset)

(OR)
13 b)
(i) Thrashing
 Excessive paging (more time swapping than executing).
 Occurs when memory is overcommitted.
 Example: Multiple large processes with limited RAM.

(ii) Swapping
 Moves processes in and out of RAM.
 Used when memory is full.
 Sketch: RAM → Disk → RAM.

14 a) Kernel I/O Subsystems


 Acts as interface between devices and applications.
 Responsibilities:
o Buffering
o Caching
o Spooling
o Device drivers
o Interrupt handling

(OR)
14 b) Disk Scheduling Algorithms
Given:
 Cylinders: 0–99
 Request sequence: 10, 22, 20, 2, 40, 6, 38
 Current head position: 20
 Seek time = 6 ms per cylinder
Algorithms:
1. FCFS:
o Order: 10 → 22 → 20 → 2 → 40 → 6 → 38
o Seek Sequence:
|20-10| + |10-22| + |22-20| + |20-2| + |2-40| + |40-6| + |6-38|
= 10 + 12 + 2 + 18 + 38 + 34 + 32 = 146 cylinders
o Total Seek Time = 146 × 6 = 876 ms
o Average Seek Time = 876 / 7 = 125.14 ms
2. SSTF (Shortest Seek Time First):
o Order (closest first from 20): 20 → 22 → 10 → 6 → 2 → 38 → 40
o Seek sequence: 0 + 2 + 12 + 4 + 4 + 36 + 2 = 60
o Total Seek Time = 60 × 6 = 360 ms
o Avg = 360 / 7 = 51.43 ms
3. LOOK:
o Head moves towards higher cylinders first then back.
o Sorted: 2, 6, 10, 20, 22, 38, 40
o Order: 20 → 22 → 38 → 40 → 10 → 6 → 2
Seek = |20-22| + |22-38| + |38-40| + |40-10| + |10-6| + |6-2| = 2 + 16 + 2 + 30 + 4 + 4 = 58
o Total Seek Time = 348 ms, Avg = 49.71 ms
4. SCAN (Elevator):
o Moves to end, then reverses.
o Order: 20 → 22 → 38 → 40 → 99 → 10 → 6 → 2
o Seek = |20-22| + |22-38| + |38-40| + |40-99| + |99-10| + |10-6| + |6-2| = 2 + 16 + 2 + 59 + 89
+ 4 + 4 = 176
o Total Seek Time = 1056 ms, Avg = 150.86 ms
5. C-SCAN:
o Moves to end, jumps to beginning, continues
o Order: 20 → 22 → 38 → 40 → 99 → 0 → 2 → 6 → 10
o Seek = 2 + 16 + 2 + 59 + 99 + 2 + 4 + 4 = 188
o Total Seek Time = 1128 ms, Avg = 161.14 ms
15 a) Mobile OS System Components
 Components:
o Kernel: Core control of hardware resources.
o Device Drivers
o UI System
o Application Framework
o Middleware
 iOS Features:
o Closed-source, tight hardware integration.
o Secure, optimized performance.
 Android Features:
o Open-source, customizable.
o Broad device support.
(OR)
15 b) Virtualization and Hypervisors
i) Virtualization Concept
 Abstracts hardware into multiple virtual environments.
 Allows multiple OS instances on the same hardware.
 Hypervisor handles CPU, memory, I/O for VMs.
ii) Type 1 vs Type 2 Hypervisors

Feature Type 1 Type 2

Install on Bare-metal (hardware) Host OS

Performance High Lower

Use case Servers, data centers Personal devices

Type 1 is preferred in server environments due to better performance and control.


PART-C 1 X 15 = 15 MARKS
16 a) Banker’s Algorithm
Given:

Process Max (A B C D) Allocation (A B C D)

P0 6012 4001

P1 1750 1000

P2 2356 1254

P3 1653 0633

P4 1656 0212

Available: A=3, B=2, C=1, D=1


i) Need Matrix = Max - Allocation

Process A B C D

P0 2 0 1 1

P1 0 7 5 0

P2 1 1 0 2

P3 1 0 2 0

P4 1 4 4 4

ii) Total Resources


Total = Allocation + Available
 A: 4+1+1+0+0 + 3 = 9
 B: 0+0+2+6+2 + 2 = 12
 C: 0+0+5+3+1 + 1 = 10
 D: 1+0+4+3+2 + 1 = 11

iii) Safe State Check


Work = [3 2 1 1]
Finish = [F F F F F]
Try to find a process whose Need ≤ Work:
 P1 → [0 7 5 0] ❌
 P0 → [2 0 1 1] ✅
Allocate: Work += Allocation of P0 → [7 2 1 2]
 P2 → [1 1 0 2] ✅
Work += P2 Alloc → [8 4 6 6]
 P3 → [1 0 2 0] ✅
Work += P3 Alloc → [8 10 9 9]
 P4 → [1 4 4 4] ✅
All processes can finish → Safe State
Safe Sequence: P0 → P2 → P3 → P4 → P1
iv) P4 requests (1 2 0 0)
Available before request: [3 2 1 1]
Check if request ≤ Available → [1 2 0 0] ≤ [3 2 1 1] ✅
New Available = [3−1 2−2 1−0 1−0] = [2 0 1 1]
New Allocation of P4 = [1 4 1 2]
New Need of P4 = Max - Alloc = [0 2 4 4]
Try safe sequence again (with updated data):
→ Proceed like before (P0 → P2 → P3 → P1 → P4 possible) ✅
Request can be granted.
(OR)
16. b (i) Paging: Page Table and Address Translation
Given:
 Logical address space: 16-bit → Total logical addresses = 2¹⁶ = 65,536
 Page size: 4 KB = 2¹² bytes → Offset = 12 bits
 Thus, Page number = upper 4 bits (16 − 12 = 4 bits) → Total pages = 2⁴ = 16
 Physical memory: 1 MB = 2²⁰ → Frame size = 4 KB → Number of frames = 2²⁰ / 2¹² = 2⁸ = 256
 Page Table Base Register (PTBR) = 1000
 Free Frame List = [13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8]
 Use this to map the first 11 logical pages (0–10) to physical frames in the given order.

Constructing the Page Table:

Page No Frame No

0 13
Page No Frame No

1 11

2 9

3 7

4 5

5 3

6 1

7 2

8 4

9 6

10 8

11–15 Not assigned (invalid or not mapped)


Find the physical address for logical address 13,256
Step 1: Convert logical address to binary:
 13,256 = 0011 0011 1110 1000 (16-bit binary)
Step 2: Break into Page number & Offset
 Page Number = upper 4 bits = 0011 = 3
 Offset = remaining 12 bits = 0011 1110 1000 = 1000 in decimal
Step 3: Get frame number for page 3 from the table:
 Page 3 → Frame 7
Step 4: Calculate Physical Address:
 Frame base = 7 × 4096 = 28,672
 Physical Address = 28,672 + 1000 = 29,672
Another logical address with page number 2 and offset 128
 Page number 2 → Frame 9
 Frame base = 9 × 4096 = 36,864
 Physical address = 36,864 + 128 = 36,992
Discuss valid-invalid and protection bits
 Valid/Invalid Bit:
o Indicates whether the page is currently in memory.
o Valid = 1: page is in physical memory
o Invalid = 0: page is not in memory (page fault if accessed)
 Protection Bits:
o Control access rights: read/write/execute
o E.g., Read-only pages, kernel-only access, etc.
o Helps in memory protection and preventing unauthorized access
16. b (ii) Paging with TLB: Effective Access Time
Given:
 Memory access time = 50 ns
 TLB access time = 2 ns
 75% of references are TLB hits
Effective Memory Access Time (EMAT) formula:
EMAT = (TLB hit rate × (TLB time + Memory time))
+ (TLB miss rate × (TLB time + 2 × Memory time))
Substituting values:
 TLB hit rate = 0.75
 TLB miss rate = 0.25
 TLB time = 2 ns
 Memory time = 50 ns
Make file
EMAT = (0.75 × (2 + 50)) + (0.25 × (2 + 2×50))
= (0.75 × 52) + (0.25 × 102)
= 39 + 25.5
= **64.5 ns**
Answer: Effective memory reference time = 64.5 nanoseconds

Prepared By Approved By
(M.Abernakumari,AP/AI&DS) (Dr.R.Murugadoss,AP/AI&DS)

You might also like