0% found this document useful (0 votes)
3 views19 pages

Operating System Interview Notes

The document provides an overview of operating systems, detailing their definition, goals, functions, major components, and types. It also covers system calls, process management, scheduling techniques, and key concepts like CPU-bound vs I/O-bound processes. Additionally, it includes interview notes and questions related to operating systems and scheduling algorithms.
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)
3 views19 pages

Operating System Interview Notes

The document provides an overview of operating systems, detailing their definition, goals, functions, major components, and types. It also covers system calls, process management, scheduling techniques, and key concepts like CPU-bound vs I/O-bound processes. Additionally, it includes interview notes and questions related to operating systems and scheduling algorithms.
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

Operating System – Simple Interview Notes (With

Examples)
1. What is an Operating System?
An Operating System (OS) is system software that acts as a middleman between user and
hardware. It helps users run programs and controls computer resources like CPU, memory, and
devices.
Think of OS like a manager in an office: - Users = employees - Hardware = machines - OS =
manager who assigns work
Example: When you open a browser, the OS loads it into memory and gives CPU time to run it.
The OS mainly does three things: - Acts as intermediary between user and hardware - Manages
resources (CPU, memory, devices) - Provides platform to run applications

2. Goals of Operating System


Goals tell us what OS tries to achieve.
Primary Goal – Convenience The OS should make the computer easy to use. Example: GUI
like Windows, macOS, Linux desktop.
Secondary Goals - Efficiency – use CPU and memory properly - Reliability – system should
not crash often - Maintainability – easy to update or modify

3. Functions of Operating System


Process Management
The OS creates and manages programs running in memory (called processes). Example: Running
Chrome and VS Code at same time.

Memory Management
The OS decides how much memory each program gets. Example: Chrome uses more RAM,
calculator uses less.

I/O Device Management


The OS controls devices like keyboard, mouse, printer. Example: When you print a file, OS
sends data to printer.

File Management
The OS organizes files and folders. Example: Creating folders, renaming files.

Network Management
The OS helps systems communicate over internet. Example: Sending data through Wi-Fi.

Security & Protection


The OS protects system from unauthorized users. Example: Login password.

4. Major Components of Operating System


Kernel The core part of OS. It directly interacts with hardware.
Process Management Handles running programs.
Memory Management Handles RAM allocation.
File System Handles files and folders.
Device Management Controls hardware devices.
User Interface Allows interaction (CLI or GUI) Example: Command prompt, desktop.
Security Controls user access.
Networking Handles communication between computers.

5. Types of Operating Systems


Batch Operating System
Jobs are grouped and executed one after another without user interaction.
Example: Old punch card systems.
Problem: CPU stays idle while waiting for input/output.

Multiprogramming Operating System


Multiple programs stay in memory at same time. If one program waits, CPU runs another.
Example: - Program A waiting for disk - CPU switches to Program B
Goal: CPU should not be idle.
Time Sharing Operating System (Multitasking)
Multiple users or programs share CPU. CPU switches very fast between tasks.
Example: - Listening to music - Browsing internet - Writing code All at same time.

Multiuser Operating System


Multiple users use same system simultaneously.
Example: Linux server with many users logged in.

Multiprocessing Operating System


System has multiple CPUs. Processes run truly in parallel.
Example: Modern multi-core processors.

Real Time Operating System


System must respond within fixed time.
Example: Airbag system in car.
Hard Real Time Deadline must not be missed. Example: Airbag, medical devices.
Soft Real Time Small delay allowed. Example: Video streaming, online games.

Distributed Operating System


Multiple computers connected and work as one system.
Example: Cloud computing systems.

6. Spooling
Spooling means storing data temporarily for slow device.
Example: Printer queue. - You give 5 print commands - All stored in queue - Printer prints one
by one
Important Differences
Multiprogramming vs Multiprocessing
Multiprogramming uses one CPU and switches tasks. Multiprocessing uses multiple CPUs and
runs tasks in parallel.

Hard vs Soft Real Time


Hard real time cannot miss deadline. Soft real time can allow small delay.

Must-Memorize Interview Lines


What is Operating System?
An Operating System is system software that acts as an intermediary between user and hardware
and manages system resources while providing an environment to run applications.

Goals of OS
The primary goal of OS is convenience, and secondary goals include efficiency, reliability, and
maintainability.

Process Management
Process management handles creation, scheduling, execution, and termination of processes.

Memory Management
Memory management allocates and deallocates memory to programs and manages virtual
memory.

Batch OS
Batch OS executes jobs in groups without user interaction.

Multiprogramming OS
Multiprogramming keeps multiple jobs in memory and switches CPU when one job waits for
I/O.

Time Sharing OS
Time sharing allows multiple users to share CPU by rapid switching between tasks.

Multiprocessing OS
Multiprocessing uses multiple CPUs to achieve true parallel execution.
Real Time OS
Real time OS responds within strict time constraints.

Spooling
Spooling stores data temporarily in memory for slow devices like printers.

Interview Questions (Topic-wise)


What is Operating System
 What is an operating system?
 What are the goals of OS?
 Why do we need an OS?

Functions of OS
 What are main functions of operating system?
 Explain process management.
 What is memory management?

Batch Operating System


 What is batch operating system?
 What are advantages of batch OS?

Multiprogramming OS
 What is multiprogramming?
 Why multiprogramming improves CPU utilization?

Time Sharing OS
 Difference between multiprogramming and time sharing?
 What is multitasking?

Multiprocessing OS
 What is multiprocessing?
 Difference between multiprogramming and multiprocessing?

Real Time OS
 What is real time operating system?
 Difference between hard and soft real time?
Spooling
 What is spooling?
 Give example of spooling.

System Calls, Process & Scheduling – Simple Notes


(With Examples)
System Call
A system call is a way for a user program to request services from the operating system. User
programs cannot directly access hardware, so they use system calls to ask the OS to perform
tasks.

Example:

 Opening a file
 Creating a process
 Printing a document

System calls act as an interface between user programs and the operating system.

Types of System Calls

Process Control Used to manage processes. Examples: create process, terminate process, wait,
allocate memory.

File Management Used to handle files. Examples: create file, open file, read, write, delete file.

Device Management Used to control devices. Examples: request device, release device,
read/write device.

Information Maintenance Used to get or set system information. Examples: get time, get
system data.

Communication Used for communication between processes. Examples: send message, receive
message.

Protection Used for security and permissions. Examples: set access rights.

User Mode and Kernel Mode


Operating system works in two modes:
User Mode Applications run in this mode. They cannot access hardware directly. Example:
Browser, text editor.

Kernel Mode Operating system runs in this mode. It has full access to hardware.

When a program makes a system call, control switches from user mode to kernel mode.

Process
A process is a program in execution. A program stored on disk becomes a process when it is
loaded into memory and starts running.

Example:

 Chrome installed → Program


 Chrome running → Process

Opening multiple Chrome windows creates multiple processes.

Process Memory Layout


Each process contains the following sections:

Text Section Contains program code.

Data Section Contains global variables.

Stack Stores function calls, local variables, return addresses.

Heap Stores dynamically allocated memory.

Program vs Process
Program is a passive entity stored on disk. Process is an active entity running in memory.
Program does not use resources, but process uses CPU and memory.
Process Control Block (PCB)
PCB is a data structure used by the operating system to store information about a process.

PCB contains:

 Process state
 Program counter
 CPU registers
 Scheduling information
 Memory information
 I/O status

Process States
A process moves through different states during execution.

New – Process is being created

Ready – Waiting for CPU

Running – Executing

Waiting – Waiting for I/O operation

Terminated – Execution finished

Process Flow: New → Ready → Running → Waiting → Ready → Running → Terminated

Schedulers
Schedulers select processes for execution.

Long Term Scheduler Selects processes from job pool and loads them into memory.

Short Term Scheduler Selects process from ready queue and assigns CPU.

Medium Term Scheduler Temporarily removes processes from memory and brings them back
later.
Dispatcher
Dispatcher gives CPU control to the process selected by short term scheduler. It performs
context switching and starts execution of selected process.

Dispatch latency is the time taken to switch from one process to another.

Must-Memorize Interview Lines


System Call: System call is an interface between user programs and operating system services.

Process: A process is a program in execution.

PCB: PCB stores all information related to a process.

Process States: A process moves between new, ready, running, waiting, and terminated states.

Scheduler: Scheduler selects processes for execution.

Dispatcher: Dispatcher gives CPU to selected process.

Interview Questions
 What is system call?
 Types of system calls?
 User mode vs kernel mode?
 What is process?
 Program vs process?
 What is PCB?
 Process states?
 Types of schedulers?
 What is dispatcher?
 Scheduler vs dispatcher?

CPU Bound vs I/O Bound Processes

Simple Idea

 CPU Bound → spends more time doing calculations


 I/O Bound → spends more time waiting for input/output (keyboard, disk, network)
Example

 CPU bound → sorting 1 million numbers


 I/O bound → downloading files from internet

Real-life analogy

 CPU bound → student solving math continuously


 I/O bound → student waiting for teacher to give next question

Context Switch

Simple Definition Switching CPU from one process to another.

What happens?

 Save old process data


 Load new process data
 Continue execution

Analogy Teacher stops Student A, starts Student B. Teacher must remember where A stopped.
Time wasted during switching = overhead

CPU Scheduling

CPU chooses which process runs next from ready queue.

Goal:

 keep CPU busy


 reduce waiting
 increase performance

Non-Preemptive Scheduling

Once CPU is given → process runs until it finishes.

Leaves CPU only when:

 finished
 needs I/O

Analogy: One person uses bathroom. Others wait until done.

Preemptive Scheduling

CPU can take away from running process.

Leaves CPU when:

 finished
 I/O request
 higher priority comes
 time slice ends

Analogy: Teacher gives 5 min per student.

Scheduling Criteria

Criteria Meaning
CPU Utilization CPU busy %
Throughput processes completed
Waiting Time time in queue
Response Time first response delay
Turnaround Time total time

Important Formulas

 Turnaround Time = CT − AT
 Waiting Time = TAT − BT

Where:

 AT = Arrival Time
 BT = Burst Time
 CT = Completion Time

FCFS (First Come First Serve)


Rule: First arrived → first executed

Characteristics:

 Non-preemptive
 FIFO queue
 simple

FCFS Example (Step by Step)

Given:

Process AT BT
P1 0 4
P2 1 3
P3 2 2

Step 1: Order by arrival → P1 → P2 → P3

Step 2: Gantt Chart

| P1 | P2 | P3 |
0 4 7 9

Step 3: Completion Time

Process CT
P1 4
P2 7
P3 9

Step 4: Turnaround Time (CT − AT)

Process TAT
P1 4−0 = 4
P2 7−1 = 6
P3 9−2 = 7

Step 5: Waiting Time (TAT − BT)

Process WT
P1 4−4 = 0
P2 6−3 = 3
P3 7−2 = 5
Average Waiting Time = (0 + 3 + 5) / 3 = 2.67

Analogy: Queue in bank. First person → served first.

Convoy Effect (FCFS Problem)

Long job first → small jobs wait long.

Example:

 P1 = 10 sec
 P2 = 1 sec
 P3 = 1 sec

Small jobs wait 10 sec.

SJF (Shortest Job First)

Rule: Smallest burst time executes first

Two types:

 Non-preemptive → SJF
 Preemptive → SRTF

SJF Example (Step by Step)

Given:

Process AT BT
P1 0 6
P2 1 2
P3 2 4

Step 1: At time 0 only P1 available → run P1 → 0 ---- 6

Step 2: At time 6 → choose shortest among P2 & P3

 P2 = 2
 P3 = 4
 Choose P2
| P1 | P2 | P3 |
0 6 8 12

Step 3: Completion Time

Process CT
P1 6
P2 8
P3 12

Step 4: Turnaround Time

Process TAT
P1 6−0 = 6
P2 8−1 = 7
P3 12−2 = 10

Step 5: Waiting Time

Process WT
P1 6−6 = 0
P2 7−2 = 5
P3 10−4 = 6

Average WT = (0 + 5 + 6) / 3 = 3.67

Analogy: Doctor treats quick patients first. Injection → 2 min. Surgery → 1 hour. Doctor
finishes small ones first.

SJF Problems:

 starvation (long job waits)


 burst time unknown

FCFS vs SJF Quick Comparison

Feature FCFS SJF


Simple Yes No
Waiting time High Low
Convoy effect Yes No
Starvation No Yes
Optimal No Yes
Quick Memory Tricks

 FCFS → arrival order


 SJF → smallest job first

PRIORITY SCHEDULING — Interview Notes

Definition CPU is allocated to the process with highest priority.

 Higher priority can be smaller number OR larger number (depends on question)


 Tie → FCFS
 Two types: Preemptive, Non-Preemptive

Non-Preemptive Priority Once CPU is assigned → process runs till completion. Even if higher
priority arrives → NO interrupt.

Preemptive Priority If a higher priority process arrives → current process is stopped


immediately.

Problem (Given)

Process AT BT Priority
P0 1 4 4
P1 2 2 5
P2 2 3 7
P3 3 5 8
P4 3 1 5
P5 4 2 6

Assume Higher number = Higher priority (because P3 marked H)

NON-PREEMPTIVE PRIORITY — Solution

Step-1: Timeline

Time 1 → Only P0 → run


Time 1–5 → P0 finishes
At time 5, available: P1, P2, P3, P4, P5. Highest priority = P3 (8)

P3 → 5–10

Remaining: P1(5), P2(7), P4(5), P5(6). Next highest = P2

P2 → 10–13

Next highest = P5

P5 → 13–15

Tie (P1, P4 priority=5) → FCFS → P1 first

P1 → 15–17
P4 → 17–18

Gantt Chart

| P0 | P3 | P2 | P5 | P1 | P4 |
1 5 10 13 15 17 18

Completion Time

Process CT
P0 5
P3 10
P2 13
P5 15
P1 17
P4 18

Turnaround Time (TAT = CT − AT)

Process CT AT TAT
P0 5 1 4
P1 17 2 15
P2 13 2 11
P3 10 3 7
P4 18 3 15
P5 15 4 11

Waiting Time (WT = TAT − BT)

Process TAT BT WT
P0 4 4 0
Process TAT BT WT
P1 15 2 13
P2 11 3 8
P3 7 5 2
P4 15 1 14
P5 11 2 9

Average WT = (0+13+8+2+14+9)/6 = 7.67

Interview Points (Priority Scheduling)

 Starvation possible
 Solution → Aging
 Used for system processes
 Can behave like SJF if priority = burst time

ROUND ROBIN — Interview Notes

Definition Each process gets fixed time quantum (q). If not finished → goes to end of queue.

Important Formula Worst waiting time: (n−1) × q

Given Problem

Process AT BT
P0 0 4
P1 1 5
P2 2 2
P3 3 1
P4 4 6
P5 6 3

Assume Time Quantum = 2

ROUND ROBIN Solution

Step-by-step

0-2 P0 (rem 2)
2-4 P1 (rem 3)
4-6 P2 (fin)
6-8 P0 (fin)
8-9 P3 (fin)
9-11 P4 (rem 4)
11-13 P1 (rem 1)
13-15 P5 (rem 1)
15-17 P4 (rem 2)
17-18 P1 (fin)
18-19 P5 (fin)
19-21 P4 (fin)

Gantt Chart

P0 P1 P2 P0 P3 P4 P1 P5 P4 P1 P5 P4
0 2 4 6 8 9 11 13 15 17 18 19 21

Completion Time

Process CT
P0 8
P1 18
P2 6
P3 9
P4 21
P5 19

TAT

Process CT AT TAT
P0 8 0 8
P1 18 1 17
P2 6 2 4
P3 9 3 6
P4 21 4 17
P5 19 6 13

WT

Process TAT BT WT
P0 8 4 4
P1 17 5 12
P2 4 2 2
P3 6 1 5
P4 17 6 11
P5 13 3 10
Interview Comparison

Feature Priority Round Robin


Preemption optional always
Starvation yes no
Response time bad best
Fairness low high
Used in real-time systems time-sharing

Most Asked Interview Questions

1. Difference between preemptive & non-preemptive priority


2. What is aging
3. When does Round Robin = FCFS → when quantum very large
4. When does Round Robin ≈ SJF → when quantum very small
5. Which has best response time → Round Robin

You might also like