0% found this document useful (0 votes)
6 views31 pages

OS Imp

An Operating System (OS) is system software that serves as an interface between users and computer hardware, managing resources and providing services to applications. Key functions include process management, memory management, file management, device management, and security. System calls allow user programs to request services from the OS, while processes are managed through a Process Control Block (PCB) that contains essential information about each process.

Uploaded by

shreemudshi0
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)
6 views31 pages

OS Imp

An Operating System (OS) is system software that serves as an interface between users and computer hardware, managing resources and providing services to applications. Key functions include process management, memory management, file management, device management, and security. System calls allow user programs to request services from the OS, while processes are managed through a Process Control Block (PCB) that contains essential information about each process.

Uploaded by

shreemudshi0
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–1 : OPERATING SYSTEM

Q1. Define Operating System and explain its functions.

(6–7 Marks)

Definition of Operating System

An Operating System (OS) is a system software that acts as an interface between the user
and computer hardware. It manages hardware resources and provides services to
application programs.

Examples: Windows, Linux, macOS, Android

Functions of Operating System

1. Process Management

o Creates, schedules, and terminates processes

o Allocates CPU to processes

o Manages process synchronization and communication

2. Memory Management

o Allocates and deallocates memory

o Keeps track of memory usage

o Supports virtual memory

3. File Management

o Creates, deletes, reads, and writes files

o Manages file permissions and directories

4. Device (I/O) Management

o Controls I/O devices using device drivers

o Manages buffering, caching, and spooling

5. Security and Protection

o Prevents unauthorized access

o Provides authentication and access control


Conclusion

Thus, the operating system ensures efficient, secure, and correct use of computer resources.

Q2. What is a System Call? Explain its types.

(7–8 Marks)

Definition of System Call

A system call is a mechanism through which a user program requests services from the
operating system kernel.

System calls provide a controlled way for programs to interact with hardware.

Types of System Calls

1. Process Control System Calls

• Create and terminate processes

• Examples: fork(), exit(), wait()

2. File Management System Calls

• Create, delete, read, and write files

• Examples: open(), read(), write(), close()

3. Device Management System Calls

• Request and release devices

• Examples: read(), write(), ioctl()

4. Information Maintenance System Calls

• Get or set system information

• Examples: getpid(), time()

5. Communication System Calls

• Enable inter-process communication

• Examples: pipe(), shared memory


Diagram (Draw in Exam)

User Program

System Call Interface

Operating System Kernel

Hardware

Q3. Define Process and explain Process Control Block (PCB).

(6–7 Marks)

Definition of Process

A process is a program in execution. It includes the program code, current activity, and
allocated resources.

Process Control Block (PCB)

A PCB is a data structure maintained by the operating system that contains all information
about a process.

Contents of PCB

1. Process ID (PID)

2. Process State (New, Ready, Running, etc.)

3. Program Counter

4. CPU Registers

5. Scheduling Information

6. Memory Management Information

7. I/O Status Information


PCB Diagram (Draw in Exam)

-----------------------

| Process ID |

| Process State |

| Program Counter |

| CPU Registers |

| Memory Info |

| I/O Info |

-----------------------

Q4. Explain different states of a Process.

(6–7 Marks)

Process States

1. New

o Process is being created

2. Ready

o Process is waiting for CPU allocation

3. Running

o Process is currently executing

4. Waiting (Blocked)

o Process is waiting for I/O or event

5. Terminated

o Process has finished execution

Process State Diagram (Draw in Exam)

New → Ready → Running → Terminated


↑ ↓

Waiting ←--

Q5. Explain different types of Operating Systems.

(6–8 Marks)

1. Batch Operating System

• Jobs are collected and executed in batches

• No user interaction

• Example: Early mainframe systems

2. Multiprogramming Operating System

• Multiple programs are kept in memory

• CPU switches between programs

• Improves CPU utilization

3. Time Sharing Operating System

• CPU time is shared among users

• Fast response time

• Example: UNIX

4. Real-Time Operating System (RTOS)

• Responds within strict time limits

• Used in control systems

• Example: Embedded systems

5. Distributed Operating System

• Multiple computers work together


• Resource sharing and load balancing

Conclusion

Different operating systems are designed to meet different user and system requirements.

Perfect
Below is an EXPANDED, DETAILED, READY-TO-WRITE version of UNIT–2, written exactly in
SPPU exam style, with extra explanations, keywords, and points so you don’t lose marks.
You can directly copy–paste and memorize this.

UNIT–2 : CPU SCHEDULING

(Operating System – SPPU)

What is CPU Scheduling?

Definition

CPU Scheduling is the process of selecting one process from the ready queue and allocating
the CPU to it so that system performance is optimized.

CPU scheduling is handled by the CPU Scheduler, which is a part of the operating system
kernel.

Need for CPU Scheduling

CPU scheduling is required to:

• Improve CPU utilization

• Increase system throughput

• Reduce waiting time and turnaround time

• Provide fairness among processes

• Improve response time for users


Scheduling Concepts & Terminology

(VERY IMPORTANT – 4 to 6 marks)

1. CPU Utilization

• Percentage of time CPU is busy executing processes

• Higher CPU utilization = better performance

2. Throughput

• Number of processes completed per unit time

3. Turnaround Time

• Total time taken from process arrival to completion

Formula:
Turnaround Time = Completion Time – Arrival Time

4. Waiting Time

• Total time a process spends waiting in the ready queue

Formula:
Waiting Time = Turnaround Time – Burst Time

5. Response Time

• Time between process submission and first response

These definitions alone can fetch easy marks.

Scheduling Algorithms (MOST IMPORTANT PART OF UNIT–2)

Scheduling algorithms decide how CPU time is distributed among processes.

First Come First Serve (FCFS / FIFO) Scheduling

(6–8 Marks – Very Scoring)

Definition

FCFS is a non-preemptive scheduling algorithm in which the CPU is allocated to the process
that arrives first in the ready queue.
Working of FCFS

• Processes are executed in arrival order

• Once CPU is allocated, it is not taken away until completion

Features

• Non-preemptive

• Simple and easy to implement

• Uses FIFO (queue) structure

Advantages

• Simple implementation

• Fair scheduling

• No starvation

Disadvantages

• High waiting time

• Convoy effect (short processes wait for long processes)

• Poor performance in time-sharing systems

Example (Write in exam)

Draw a simple Gantt chart to explain execution order.

Numericals are commonly asked from FCFS.

Shortest Job First (SJF) Scheduling

(6–8 Marks – Important)

Definition
SJF is a scheduling algorithm in which the CPU is allocated to the process having the shortest
CPU burst time.

Types of SJF

1. Non-Preemptive SJF

• Once CPU is allocated, it cannot be taken back

• Process runs till completion

2. Preemptive SJF (Shortest Remaining Time First – SRTF)

• CPU is allocated to the process with shortest remaining time

• Current process can be preempted

Advantages

• Minimum average waiting time

• Efficient CPU utilization

Disadvantages

• Starvation of long processes

• Burst time prediction is difficult

• Not suitable for interactive systems

Mention both types to score full marks.

Round Robin (RR) Scheduling

(6–8 Marks – Examiner Favourite)

Definition

Round Robin is a preemptive scheduling algorithm in which each process is assigned a fixed
time quantum and CPU is allocated in a circular order.
Working of Round Robin

• CPU is given to a process for a fixed time quantum (TQ)

• If process finishes within TQ → it leaves

• If not → it is preempted and placed at the end of ready queue

Features

• Preemptive

• Uses circular queue

• Designed for time-sharing systems

Advantages

• Fair to all processes

• No starvation

• Good response time

Disadvantages

• Performance depends on size of time quantum

• Too small TQ → overhead increases

• Too large TQ → behaves like FCFS

Always write “Time Quantum” clearly in exam.

Comparative Study

(4–6 Marks – Easy Table Question)

Comparison: FCFS vs SJF vs Round Robin

Parameter FCFS SJF Round Robin

Type Non-preemptive Pre/Non Preemptive

Waiting Time High Minimum Moderate


Parameter FCFS SJF Round Robin

Starvation No Yes No

Response Time Poor Good Best

Use Case Batch systems CPU-efficient Time-sharing

High Priority Topic

Multi-Level Feedback Queue (MLFQ)

(6 Marks – Theory)

• Uses multiple queues with different priorities

• Processes can move between queues

• Priority changes dynamically based on behavior

• Prevents starvation

Draw simple multi-queue diagram for extra marks.

Medium Priority (Read Once)

• Incorporating I/O in scheduling

• Priority Boost

• Better Accounting

(Definitions + 2–3 points are enough)

Numerical Problems (VERY IMPORTANT)

Be ready to calculate:

• Completion Time

• Turnaround Time

• Waiting Time

For:

• FCFS
• SJF

• Round Robin

Practicing 1 numerical per algorithm is sufficient.

Topics You Can Skip (If Time Is Less)

• Linux multiprocessor scheduling internals

• xv6 case study (only read summary)

Can You Score FULL 14 Marks from Unit–2?

YES, if you prepare:

• FCFS

• SJF

• Round Robin

• Scheduling terms

UNIT–3 : ADDRESS SPACES & MEMORY MANAGEMENT

(Operating System – SPPU)

Q1. Explain Paging in detail.

(6–8 Marks)

Definition

Paging is a memory management technique in which the logical memory of a process is


divided into fixed-size pages, and physical memory is divided into frames of the same size.

The operating system maintains a page table to map pages to frames.

Working of Paging

1. Logical memory is divided into pages

2. Physical memory is divided into frames


3. Page table stores page number → frame number mapping

4. CPU generates logical address

5. MMU converts it into physical address using page table

Address Structure

• Logical Address = Page Number + Offset

• Physical Address = Frame Number + Offset

Advantages

• Eliminates external fragmentation

• Efficient memory utilization

• Allows virtual memory

Disadvantages

• Internal fragmentation

• Page table overhead

Diagram (Draw in Exam)

Logical Address → Page Table → Physical Memory

(Page No + Offset) (Frame No + Offset)

Q2. Explain Address Translation in Paging.

(6 Marks)

Definition

Address translation is the process of converting a logical (virtual) address into a physical
address using paging mechanism.

Steps of Address Translation


1. CPU generates logical address

2. Logical address is divided into:

o Page number

o Offset

3. Page number is used to index page table

4. Frame number is obtained

5. Frame number + offset gives physical address

Role of MMU

The Memory Management Unit (MMU) performs address translation automatically.

Importance

• Provides isolation between processes

• Ensures memory protection

• Supports virtual memory

Q3. Explain Page Fault and its Handling Steps.

(6–8 Marks)

Definition

A page fault occurs when a process tries to access a page that is not present in main
memory.

Page Fault Handling Steps

1. CPU references a page

2. Page table indicates page is not in memory

3. Page fault interrupt occurs

4. OS suspends process

5. Required page is fetched from secondary memory


6. Page is placed in a free frame

7. Page table is updated

8. Process resumes execution

Diagram (Optional)

Secondary Memory → Main Memory → Page Table Update

Conclusion

Page faults enable efficient use of memory by loading pages only when required.

Q4. Explain Virtual Memory in detail.

(6–8 Marks)

Definition

Virtual memory is a technique that allows execution of processes even when they are not
completely present in main memory.

It gives the illusion of large memory to the user.

Working of Virtual Memory

• Uses secondary storage (disk)

• Pages are loaded on demand

• Uses paging and page replacement algorithms

Advantages

• Programs larger than RAM can execute

• Better memory utilization

• Increased degree of multiprogramming

Disadvantages
• Page fault overhead

• Slower than main memory

Conclusion

Virtual memory improves system performance and flexibility.

Q5. Differentiate between Physical Memory and Virtual Memory.

(4–6 Marks)

Parameter Physical Memory Virtual Memory

Location RAM Disk + RAM

Speed Fast Slower

Size Limited Large

Cost Expensive Cheaper

Usage Actual storage Logical abstraction

Q6. Explain Translation Lookaside Buffer (TLB).

(6 Marks)

Definition

TLB is a small, fast cache memory that stores recent page table entries to speed up address
translation.

Working of TLB

1. CPU generates logical address

2. MMU checks TLB first

3. If page found → TLB hit → fast access

4. If not found → TLB miss → page table lookup


Advantages

• Faster memory access

• Reduces page table access time

Diagram (Draw in Exam)

CPU → TLB → Page Table → Memory

Q7. Explain Segmentation in detail.

(6–8 Marks)

Definition

Segmentation is a memory management technique in which a process is divided into


variable-size logical segments such as:

• Code segment

• Data segment

• Stack segment

Segment Table

Each segment contains:

• Segment number

• Base address

• Limit

Advantages

• Logical memory organization

• Supports sharing and protection

Disadvantages

• External fragmentation
• Complex memory management

Diagram

Logical Segments → Physical Memory

Q8. Differentiate between Segmentation and Paging.

(6 Marks – VERY IMPORTANT)

Parameter Segmentation Paging

Size Variable Fixed

Fragmentation External Internal

View Logical Physical

Programmer View Visible Invisible

Address Format Segment + Offset Page + Offset

UNIT–4 : CONCURRENCY

(Operating System – SPPU)

Q1. Explain Concurrency in Operating System in detail.

(6–8 Marks)

Definition

Concurrency refers to the ability of an operating system to execute multiple processes or


threads in overlapping time periods, where these processes may share common system
resources such as memory, files, or devices.

Concurrency does not necessarily mean parallel execution. Even on a single CPU system,
concurrency is achieved by rapid context switching.

Why Concurrency is Required


Concurrency is essential to:

1. Improve CPU utilization

2. Increase system throughput

3. Allow resource sharing

4. Improve responsiveness in interactive systems

5. Support multiprogramming and multitasking

Problems Caused by Concurrency

1. Race Condition
Occurs when multiple processes access shared data simultaneously and the final
result depends on execution order.

2. Deadlock
Processes wait indefinitely for resources held by each other.

3. Starvation
A process never gets CPU or resources due to scheduling or priority issues.

Conclusion

Concurrency improves performance but requires synchronization mechanisms to ensure


correctness and data consistency.

Q2. Explain Semaphore in detail.

(7–8 Marks – VERY IMPORTANT)

Definition

A Semaphore is a synchronization primitive used to control access to shared resources in a


concurrent system.

It is an integer variable that can be accessed only through two atomic operations:

• wait() (P)

• signal() (V)

Semaphore Operations
wait() / P() Operation

• Decrements semaphore value

• If value becomes negative, the calling process is blocked

• Ensures controlled entry to critical section

signal() / V() Operation

• Increments semaphore value

• If any process is blocked, one is woken up

Types of Semaphores

1. Binary Semaphore

• Value = 0 or 1

• Used for mutual exclusion

• Only one process can enter critical section

• Similar to mutex lock

2. Counting Semaphore

• Value can be greater than 1

• Used when multiple identical resources exist

• Controls access based on resource count

Advantages of Semaphore

• Prevents race condition

• Flexible synchronization

• Works for both processes and threads

Disadvantages of Semaphore

• Deadlock possible if not used carefully

• Difficult to debug

• Incorrect order of wait() and signal() causes errors


Conclusion

Semaphores are powerful but must be used carefully to avoid synchronization problems.

Q3. Explain Producer–Consumer Problem using Semaphore.

(7–8 Marks – CLASSICAL QUESTION)

Problem Statement

The Producer–Consumer problem involves two types of processes:

• Producer produces data and puts it into a buffer

• Consumer consumes data from the buffer

The buffer is shared, so synchronization is required.

Issues

• Producer must wait if buffer is full

• Consumer must wait if buffer is empty

• Mutual exclusion needed while accessing buffer

Semaphores Used

1. mutex – ensures mutual exclusion

2. empty – counts empty slots

3. full – counts filled slots

Working

• Producer:

o wait(empty)

o wait(mutex)

o produce item

o signal(mutex)
o signal(full)

• Consumer:

o wait(full)

o wait(mutex)

o consume item

o signal(mutex)

o signal(empty)

Conclusion

Semaphores ensure correct synchronization, prevent race condition, and maintain buffer
consistency.

Q4. Explain Reader–Writer Problem in detail.

(7–8 Marks)

Problem Statement

The Reader–Writer problem involves:

• Multiple readers accessing shared data

• One or more writers modifying the data

Rules

1. Multiple readers can read simultaneously

2. Only one writer can write at a time

3. No reader should read while writer is writing

Types of Reader–Writer Problems

1. Reader Priority
Readers are never delayed, writers may starve

2. Writer Priority
Writers get preference, readers may wait
Synchronization

Semaphores are used to:

• Allow concurrent reading

• Ensure exclusive writing

• Prevent race conditions

Conclusion

The Reader–Writer problem highlights fair resource sharing and synchronization


challenges.

Q5. Explain Dining Philosopher Problem.

(7–8 Marks – DEADLOCK EXAMPLE)

Problem Statement

Five philosophers sit around a circular table.


Each philosopher:

• Thinks

• Eats

• Needs two forks (left & right) to eat

Deadlock Situation

If all philosophers pick up one fork simultaneously, none can eat → deadlock.

Conditions Causing Deadlock

1. Mutual exclusion

2. Hold and wait

3. No preemption

4. Circular wait
Solutions

• Allow only one philosopher to eat at a time

• Use semaphore to limit number of philosophers

• Break circular wait condition

Conclusion

Dining Philosopher problem demonstrates deadlock and resource allocation issues.

Q6. Differentiate between Process and Thread.

(6–7 Marks – VERY SCORING)

Parameter Process Thread

Definition Program in execution Lightweight process

Memory Separate address space Shared address space

Creation Slow Fast

Context Switch Heavy Light

Communication IPC required Easy (shared memory)

Failure Impact Isolated Affects process

Q7. Explain Life Cycle of a Thread.

(6–7 Marks)

Thread States

1. New – Thread is created

2. Ready – Waiting for CPU

3. Running – Executing instructions

4. Waiting / Blocked – Waiting for event/resource

5. Terminated – Execution completed


Diagram (VERY IMPORTANT)

New → Ready → Running → Terminated

↑ ↓

Waiting ←--

Conclusion

Thread life cycle allows OS to manage execution efficiently and improve concurrency.

UNIT–5 : I/O MANAGEMENT

(Operating System – SPPU)

Q1. Explain Canonical Device in detail.

(6–8 Marks)

Definition

A Canonical Device is an idealized or simplified model of an I/O device used by the


operating system to provide a uniform and standard interface for handling different types of
hardware devices.

The operating system treats all I/O devices as canonical devices to hide hardware
complexity from the user and applications.

Need for Canonical Device

• Different I/O devices have different speeds and behaviors

• Direct handling of each device increases OS complexity

• Canonical device provides device independence

Characteristics of Canonical Device

1. Provides a standard interface

2. Supports sequential access

3. Handles blocking and non-blocking I/O


4. Works using read and write operations

Registers Used in Canonical Device

• Data Register – stores data being transferred

• Status Register – indicates device status

• Control Register – controls device operations

Advantages

• Simplifies I/O system design

• Makes OS device-independent

• Easy to implement device drivers

Conclusion

Canonical devices help the OS manage diverse I/O hardware using a common abstraction
model.

Q2. Explain Canonical Protocol.

(6–8 Marks)

Definition

The Canonical Protocol is a standard sequence of steps followed by the operating system to
perform I/O operations on canonical devices.

It defines how data is transferred between CPU, memory, and I/O devices.

Steps of Canonical Protocol

1. Process Issues I/O Request


The user process requests I/O using system calls like read() or write().

2. OS Invokes Device Driver


The OS passes the request to the appropriate device driver.
3. Driver Initializes Device Registers
Control, status, and data registers are configured.

4. Data Transfer Begins


Data is transferred between device and memory.

5. Interrupt Generated
Device sends an interrupt to signal completion.

6. OS Handles Interrupt
OS updates status and wakes the waiting process.

Advantages

• Standardized I/O handling

• Efficient synchronization

• Device-independent operations

Conclusion

Canonical protocol ensures correct, reliable, and uniform I/O operations.

Q3. Explain Device Driver in detail.

(6–8 Marks – VERY IMPORTANT)

Definition

A Device Driver is a system software module that acts as an interface between the
operating system and hardware devices.

It translates OS-level commands into device-specific instructions.

Functions of Device Driver

1. Initializes the device

2. Converts OS requests into hardware commands

3. Handles interrupts

4. Performs error handling


5. Manages device status

Types of Device Drivers

• Character device drivers (keyboard, mouse)

• Block device drivers (hard disk, SSD)

Advantages

• Hardware abstraction

• Modularity

• Easy hardware replacement

Conclusion

Device drivers make the OS hardware-independent and extensible.

Q4. Explain IDE Disk Driver and its Working.

(6–8 Marks)

Definition

An IDE (Integrated Drive Electronics) Disk Driver is a block device driver that allows the OS
to communicate with IDE hard disks.

Working of IDE Disk Driver

1. OS Sends Read/Write Request


File system sends block I/O request.

2. IDE Driver Translates Request


Converts request into disk-specific commands.

3. Disk Controller Executes Command


Disk performs read/write operation.

4. Data Transfer Occurs


Data moves between disk and memory.
5. Interrupt Generated
Disk signals completion.

6. Driver Updates OS
OS resumes the blocked process.

Features

• Supports block-based access

• Handles disk scheduling

• Performs error checking

Conclusion

IDE disk drivers enable efficient disk I/O using interrupts.

Q5. Explain Disk Failure Modes.

(6–8 Marks)

Definition

Disk failure modes refer to the different ways in which a disk can fail, leading to data loss or
corruption.

Types of Disk Failure Modes

1. Head Crash

• Read/write head touches disk surface

• Causes permanent data damage

2. Bad Sectors

• Certain disk sectors become unreadable

• Detected using error-checking codes

3. Controller Failure

• Disk controller stops functioning

• Disk becomes inaccessible


4. Power Failure

• Sudden power loss during write operation

• Results in corrupted data

Prevention Techniques

• Disk redundancy

• Regular backups

• Error detection mechanisms

Conclusion

Understanding disk failure modes helps in designing reliable storage systems.

Q6. Explain Checksum and its Working.

(6–8 Marks – VERY SCORING)

Definition

A Checksum is an error-detection technique used to verify data integrity during


transmission or storage.

Working of Checksum

At Sender Side

1. Data is divided into fixed-size blocks

2. Blocks are added together

3. Result is complemented to form checksum

4. Checksum is sent along with data

At Receiver Side

1. Received data blocks are added

2. Received checksum is added


3. If result = 0 → no error

4. Otherwise → error detected

Advantages

• Simple to implement

• Detects common transmission errors

Limitations

• Cannot detect all errors

• Less reliable than CRC

Conclusion

Checksum provides basic but effective error detection in I/O systems.

You might also like