OPERATING SYSTEM KA FALTU GYAN
Unit 1: Operating System Overview
Q1. Define Operating System. Explain its two views with examples.
Answer:
An Operating System (OS) is a software that works as an interface between
the user and the computer hardware. It manages all hardware resources (CPU,
memory, input/output devices) and provides services so that users and
applications can run easily.
Two Views of OS:
1. User View:
• From the user’s point of view, the OS makes the computer easy to
use.
• Example: Windows provides a graphical interface (icons, files,
menus). Android allows users to touch and run apps.
• Users don’t need to know how hardware works; they just use
applications.
2. System View (Resource Manager):
• From the system’s point of view, the OS manages hardware
resources like CPU, RAM, and I/O devices.
• Example: The OS decides which process will use the CPU, how
much memory is allocated, and when an input/output device can
be used.
• This ensures efficiency and prevents conflicts.
Conclusion:
Thus, OS is both a user-friendly interface and a resource manager.
Q2. Describe Real-Time Operating Systems and Batch Operating Systems, and
explain their advantages and disadvantages.
Answer:
1. Real-Time Operating System (RTOS):
• RTOS is designed to give quick response and process data within
strict time limits.
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
• Example: Air traffic control systems, robotics, medical equipment.
Advantages:
• Provides fast response.
• Suitable for critical applications.
• High reliability.
Disadvantages:
• Very costly to design.
• Complex to program and maintain.
• Requires powerful hardware.
2. Batch Operating System:
• In batch OS, similar jobs are collected together and executed one
by one, without user interaction during execution.
• Example: Early IBM mainframe computers used batch processing.
Advantages:
• Simple and easy to use.
• Utilizes CPU well for long jobs.
• Suitable for repetitive tasks.
Disadvantages:
• No interaction with user while running.
• Debugging is difficult.
• Waiting time is high.
Conclusion:
RTOS is used for time-sensitive tasks, while Batch OS is useful for large
repetitive jobs.
Q3. Differentiate between Multiprogramming and Multitasking OS.
Answer:
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
1. Multiprogramming OS:
• More than one program is kept in memory and the CPU executes
them one by one.
• The goal is to keep CPU busy by switching to another job when
one job waits for I/O.
• Example: Early mainframes.
2. Multitasking OS:
• More than one task/program is executed by the CPU at the same
time by switching rapidly.
• Users feel that all tasks are running simultaneously.
• Example: Windows, Linux, macOS.
Difference Table:
Aspect Multiprogramming Multitasking
Goal Maximize CPU utilization Give fast response to users
Execution Jobs selected one by one Tasks switch rapidly
User Usually single user Multiple users/applications
Example Old IBM systems Windows, Android
Conclusion:
Multiprogramming increases CPU efficiency, while Multitasking increases user
interaction and responsiveness.
Q4. Explain Multiprocessing OS in detail. Differentiate between symmetric
and asymmetric multiprocessing.
Answer:
Multiprocessing OS:
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
• In multiprocessing, the computer has two or more CPUs working
together.
• OS manages these processors to run tasks faster.
• Example: Modern servers, supercomputers.
Types:
1. Symmetric Multiprocessing (SMP):
• All processors are equal and share memory.
• Each processor can perform any task.
• Example: Windows, Linux servers.
2. Asymmetric Multiprocessing (AMP):
• One processor is the master, others are slaves.
• Master controls the system, assigns jobs to other processors.
• Example: Some embedded systems.
Difference Table:
Aspect Symmetric (SMP) Asymmetric (AMP)
Control All processors equal One master, others slaves
High (if one fails, others Low (if master fails, system
Reliability continue) stops)
Complexity More complex Simpler
Conclusion:
SMP is used in modern multiprocessor systems, AMP is used in special-
purpose systems.
Q5. What is a System Call? Explain step-by-step execution of a system call.
Answer:
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
System Call:
• It is a way for a program to request services from the OS (like reading a
file, printing data, or creating a process).
• Example: read(), write(), fork() in UNIX.
Steps of System Call Execution:
1. User program makes a request (e.g., read file).
2. Request goes to the system call interface.
3. CPU switches from user mode → kernel mode.
4. OS performs the service (e.g., read data from disk).
5. OS returns result to the user program.
6. CPU switches back to user mode.
Conclusion:
System calls are the bridge between user programs and the OS kernel.
Q6. Short Notes:
a) System Programs:
• These are programs provided by OS to help users and developers.
• Examples: File management tools, text editors, compilers, assemblers.
b) Application Programs:
• These are user-level programs used for specific tasks.
• Examples: MS Word, Google Chrome, Games.
Q7. Compare Monolithic and Microkernel OS Structures with diagrams.
Answer:
1. Monolithic Kernel:
• All OS services (process mgmt, file system, device drivers) run
inside the kernel.
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
• Fast but large and difficult to maintain.
• Example: UNIX, Linux.
2. Microkernel:
• Only essential services (CPU scheduling, IPC, memory
management) run in the kernel.
• Other services run in user space.
• More secure and modular.
• Example: MacOS, QNX.
Diagram (simple):
• Monolithic: [Applications] → [Big Kernel (All services)]
• Microkernel: [Applications] → [Microkernel (only core)] + [User services
outside]
Difference:
Aspect Monolithic Microkernel
Speed Fast Slower
Security Less secure More secure
Complexity Hard to maintain Easier
Q8. Explain different OS Structures (Layered, Microkernel, Modular, Hybrid).
Answer:
1. Layered OS:
• OS is divided into layers, each layer built on top of the lower one.
• Example: THE OS.
2. Microkernel OS:
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
• Only basic services in kernel, rest outside.
• Example: QNX.
3. Modular OS:
• Combines advantages of monolithic and microkernel.
• OS components are loadable modules.
• Example: Linux modules.
4. Hybrid OS:
• Mix of monolithic and microkernel design.
• Example: Windows, MacOS.
Q9. Compare Monolithic and Microkernel Structures in detail. Why is
microkernel considered more secure but less efficient?
Answer:
Comparison:
• Monolithic: All services in kernel → fast but less secure.
• Microkernel: Only basic services in kernel → secure but slower (extra
communication).
Why Microkernel More Secure but Less Efficient?
• Secure: Because most services run in user space. Even if one crashes,
kernel is safe.
• Less Efficient: Extra communication (message passing) between user and
kernel makes it slower.
Unit 2: Process Management
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
Q10. Differentiate between Process and Program with examples.
Answer:
1. Program:
• A program is a set of instructions written to perform a task.
• It is a passive entity (just stored in file).
• Example: sum.c file in C language.
2. Process:
• A process is a program in execution.
• It is an active entity (has program counter, registers, memory).
• Example: When we run sum.c, the running task becomes a
process.
Difference Table:
Aspect Program Process
State Passive (on disk) Active (in execution)
Memory No memory assigned Uses CPU, RAM, I/O
Existence Just code Code + current state
Example MS Word file Running MS Word app
Conclusion:
Program = Recipe (instructions), Process = Cooking (execution).
Q11. Explain how process attributes are defined and discuss how the Process
Control Block (PCB) helps manage these attributes.
Answer:
Each process has attributes that describe its current state:
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
1. Process ID (unique number).
2. Process State (ready, running, waiting).
3. Program Counter (next instruction address).
4. CPU Registers.
5. Memory Information.
6. I/O Information.
All these details are stored in a special data structure called Process Control
Block (PCB).
Role of PCB:
• PCB is like the identity card of a process.
• OS uses PCB to keep track of all processes.
• When CPU switches from one process to another (context switch), PCB
stores old process data and loads new one.
Conclusion:
PCB is the backbone of process management in OS.
Q12. What are the goals of Process Scheduling? Explain briefly.
Answer:
Process Scheduling means deciding which process gets the CPU and for how
long.
Goals:
1. Maximize CPU utilization – CPU should not sit idle.
2. Minimize waiting time – Reduce time a process spends in ready queue.
3. Minimize turnaround time – Finish jobs quickly.
4. Minimize response time – Give fast response in interactive systems.
5. Fairness – All processes should get a chance.
6. Throughput – Maximize number of processes completed in given time.
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
Conclusion:
Scheduling ensures efficient, fair, and fast process execution.
Q13. Solve using FCFS Scheduling. Draw Gantt chart and calculate Waiting
Time, Turnaround Time, Average TAT and Average WT.
Given:
Process Arrival Time Burst Time
P1 0 2
P2 1 2
P3 5 3
P4 6 4
Solution (FCFS = First Come First Serve):
1. Arrange by arrival time.
2. Draw Gantt Chart:
0 - 2 2 - 4 5 - 8 8 - 12
[P1] [P2] [P3] [P4]
Calculations:
• Turnaround Time (TAT) = Completion - Arrival
• Waiting Time (WT) = TAT - Burst
Process AT BT CT TAT WT
P1 0 2 2 2 0
P2 1 2 4 3 1
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
Process AT BT CT TAT WT
P3 5 3 8 3 0
P4 6 4 12 6 2
• Average TAT = (2+3+3+6)/4 = 14/4 = 3.5
• Average WT = (0+1+0+2)/4 = 3/4 = 0.75
Q14. Explain Shortest Job First (SJF) Scheduling with example.
Answer:
SJF Scheduling:
• Process with smallest burst time is executed first.
• Can be Preemptive (SRTF) or Non-preemptive.
Example (Non-preemptive):
Processes: P1(6), P2(8), P3(7), P4(3)
Execution order = P4 → P1 → P3 → P2
Advantages:
• Minimum average waiting time.
• Efficient for batch systems.
Disadvantages:
• Hard to predict burst time.
• Starvation may occur (long processes wait too much).
Q15. Solve using SJF. Draw Gantt chart and calculate Waiting Time,
Turnaround Time, Average TAT and Average WT.
Given:
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
Process AT BT
P1 1 3
P2 2 4
P3 1 2
P4 4 4
Solution (SJF Non-preemptive):
1. At time=1, P1 & P3 available → choose P3 (BT=2).
2. Next → P1 (BT=3).
3. At time=6, P2 & P4 available → choose P2 (BT=4).
4. Then P4.
Gantt Chart:
1 - 3 3 - 6 6 - 10 10 - 14
[P3] [P1] [P2] [P4]
Calculations:
Process AT BT CT TAT WT
P1 1 3 6 5 2
P2 2 4 10 8 4
P3 1 2 3 2 0
P4 4 4 14 10 6
• Avg TAT = (5+8+2+10)/4 = 25/4 = 6.25
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
• Avg WT = (2+4+0+6)/4 = 12/4 = 3
Q18. Solve using Round Robin Scheduling (Time Quantum = 2). Draw Gantt
chart and calculate Waiting Time, Turnaround Time, Average TAT, Average WT
and Avg Response Time.
Given:
Process AT BT
P1 0 5
P2 1 4
P3 2 2
P4 4 1
Solution (RR, TQ=2):
Gantt Chart:
0-2 2-4 4-6 6-7 7-9 9-10 10-11
[P1] [P2] [P3] [P1] [P2] [P1] [P4]
Calculations:
Process AT BT CT TAT WT RT
P1 0 5 10 10 5 0
P2 1 4 9 8 4 1
P3 2 2 6 4 2 2
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
Process AT BT CT TAT WT RT
P4 4 1 11 7 6 6
• Avg TAT = (10+8+4+7)/4 = 29/4 = 7.25
• Avg WT = (5+4+2+6)/4 = 17/4 = 4.25
• Avg RT = (0+1+2+6)/4 = 9/4 = 2.25
Q19. What is Priority Scheduling? Explain with advantages and
disadvantages.
Answer:
Priority Scheduling:
• Each process is given a priority number.
• The process with highest priority runs first.
Advantages:
• Important tasks get executed early.
• Works well for real-time systems.
Disadvantages:
• Low priority processes may starve (wait forever).
• Needs extra logic to assign priorities.
Solution for starvation: Aging (increase priority of waiting processes).
Q20. Differentiate between User-level Threads and Kernel-level Threads with
examples.
Answer:
1. User-Level Threads (ULT):
• Managed by user libraries, not by kernel.
Made by Dev Pratap Singh
OPERATING SYSTEM KA FALTU GYAN
• Faster, less overhead.
• Example: POSIX threads.
• Problem: If one thread blocks, all block.
2. Kernel-Level Threads (KLT):
• Managed by OS kernel.
• Slower but more powerful.
• Example: Windows threads, Linux kernel threads.
Difference Table:
Aspect User-Level Threads Kernel-Level Threads
Managed by User library OS kernel
Speed Fast Slower
Blocking All threads blocked if one blocks Other threads keep running
Example Java threads Windows/Linux threads
Made by Dev Pratap Singh