Saturday, June 20, 2026

OS_IMP

UNIT=1

Explain Process States (7 Marks – GTU Style)

A process is a program that is currently running in the computer. During execution, a process changes from one state to another. These states are called process states. The operating system keeps track of each process and manages its movement between states.

Process states help the operating system in CPU scheduling, resource allocation, and multitasking.

Diagram of Process States:

        New
         |
         v
       Ready
         |
         v
      Running
      /     \
     v       v
 Waiting    Terminated
     |
     v
   Ready


Different Process States

1. New State

  • This is the first state of a process.

  • In this state, the process is being created.

  • The operating system allocates memory and other resources.

  • The process is not ready for execution yet.

Example: When we click on an application icon, the process is created.


2. Ready State

  • In this state, the process is ready to run.

  • It waits for CPU allocation.

  • The process stays in the ready queue.

  • Multiple processes can be in ready state.

Example: If many programs are open, they wait in ready state.


3. Running State

  • In this state, the process is executing on the CPU.

  • Only one process can run at one time in a single processor system.

  • The process performs its task.

Example: While typing in a text editor.


4. Waiting (Blocked) State

  • Sometimes a process needs input/output operations.

  • During this time, it cannot use CPU.

  • So it moves to waiting state.

  • It waits until the event is completed.

Example: Waiting for data from disk.


5. Terminated State

  • When the process finishes its work, it enters this state.

  • The operating system removes it from memory.

  • Resources used by the process are released.

Example: Closing an application after use.


State Transitions

New → Ready

  • The process is admitted into the ready queue.

Ready → Running

  • CPU is assigned by the scheduler.

Running → Waiting

  • The process requests I/O operation.

Waiting → Ready

  • After I/O completion, the process becomes ready again.

Running → Ready

  • If CPU time is over, the process goes back to ready state.

Running → Terminated

  • When execution is completed.


Importance of Process States

  • Helps in proper CPU management.

  • Improves system performance.

  • Supports multitasking.

  • Makes scheduling easier.


Conclusion

Process states are important in operating systems because they show the life cycle of a process. The operating system uses these states to control process execution and utilize CPU efficiently.


Explain Thread and its States (7 Marks – GTU Style)

A thread is the smallest unit of execution inside a process. It is also called a lightweight process. A process can have one or more threads. Threads share the same memory and resources of the process.

For example, in a browser, one thread can download data while another thread displays the page.

Threads make program execution faster and improve CPU utilization.


Definition of Thread

A thread is a sequence of instructions that can run independently within a process.

A process contains:

  • Program code

  • Data section

  • Files

  • Resources

A thread contains:

  • Thread ID

  • Program counter

  • Register set

  • Stack


Advantages of Thread

1. Fast Execution

Threads run tasks simultaneously, so execution becomes faster.

2. Resource Sharing

Threads share memory and resources of the same process.

3. Better CPU Utilization

CPU remains busy by executing multiple threads.

4. Easy Communication

Communication between threads is easier than between processes.


States of a Thread

A thread also passes through different states during execution.

Diagram of Thread States:

       New
        |
        v
      Ready
        |
        v
     Running
     /     \
    v       v
 Blocked   Terminated
    |
    v
  Ready

1. New State

  • The thread is created in this state.

  • It is not yet ready for execution.

Example: Creating a new thread in a program.


2. Ready State

  • The thread is ready to run.

  • It waits for CPU allocation.

Example: Thread waiting in queue.


3. Running State

  • The thread is currently executing on CPU.

  • It performs its assigned task.

Example: Downloading a file.


4. Blocked (Waiting) State

  • The thread waits for some event like I/O completion.

  • It cannot execute during this state.

Example: Waiting for user input.


5. Terminated State

  • The thread completes its task.

  • It is removed from the system.

Example: File download finished.


Difference Between Process and Thread

ProcessThread
Process is heavy weight.Thread is light weight.
It has separate memory.It shares process memory.
Creation takes more time.Creation takes less time.
Communication is slower.Communication is faster.

Conclusion

A thread is an important part of modern operating systems. It improves performance by dividing work into smaller tasks. Thread states help the operating system manage thread execution efficiently.

Compare FCFS, SJF and RR Scheduling (7 Marks – GTU Style)

CPU scheduling is the process of selecting which process will get the CPU for execution. Different scheduling algorithms are used to improve CPU utilization and reduce waiting time. The three important scheduling algorithms are FCFS, SJF, and RR.


1. FCFS (First Come First Serve)

In this scheduling, the process that arrives first gets the CPU first. It works like a queue.

Features:

  • Simple and easy to implement.

  • It follows FIFO (First In First Out).

  • It is a non-preemptive scheduling algorithm.

  • Once CPU is assigned, the process runs until completion.

Advantages:

  • Easy to understand.

  • No starvation problem.

Disadvantages:

  • Average waiting time is high.

  • Short processes may wait for a long time.


2. SJF (Shortest Job First)

In this scheduling, the process with the smallest burst time is executed first.

Features:

  • It gives minimum average waiting time.

  • It can be preemptive or non-preemptive.

  • Burst time must be known before execution.

Advantages:

  • Best performance in terms of waiting time.

  • Better CPU utilization.

Disadvantages:

  • Difficult to know exact burst time.

  • Long processes may suffer starvation.


3. RR (Round Robin)

In this scheduling, each process gets CPU for a fixed time called time quantum.

Features:

  • It is a preemptive scheduling algorithm.

  • After time quantum ends, the process goes back to ready queue.

  • Each process gets equal chance.

Advantages:

  • Good for time-sharing systems.

  • Fair CPU allocation.

  • Better response time.

Disadvantages:

  • Performance depends on time quantum.

  • Too small quantum increases overhead.


Comparison Table

BasisFCFSSJFRR
MeaningFCFS executes the process in the order of arrival.SJF executes the process with the shortest burst time first.RR executes each process for a fixed time quantum.
NatureFCFS is a non-preemptive scheduling algorithm.SJF can be preemptive or non-preemptive.RR is a preemptive scheduling algorithm.
Process SelectionIn FCFS, the first arrived process gets CPU first.In SJF, the shortest job gets CPU first.In RR, all processes get CPU one by one.
Waiting TimeFCFS usually gives high waiting time.SJF gives minimum waiting time.RR gives average waiting time.
Response TimeFCFS has slower response time.SJF has better response time than FCFS.RR has fast response time because every process gets CPU quickly.
StarvationFCFS does not cause starvation.SJF may cause starvation for long jobs.RR does not cause starvation because all processes get equal chance.
ComplexityFCFS is simple and easy to implement.SJF is more difficult because burst time must be known.RR is easy but needs time quantum management.
FairnessFCFS is fair according to arrival order.SJF is not fully fair because short jobs get priority.RR is fair because each process gets equal CPU time.
PerformanceFCFS gives lower performance in many cases.SJF gives better performance and high CPU utilization.RR gives good performance in time-sharing systems.
Suitable ForFCFS is suitable for batch processing systems.SJF is suitable for short jobs.RR is suitable for interactive and time-sharing systems.

Example

Suppose three processes:

ProcessBurst Time
P18 ms
P24 ms
P32 ms
  • FCFS: P1 → P2 → P3

  • SJF: P3 → P2 → P1

  • RR (Time quantum = 2 ms): P1 → P2 → P3 → P1 → P2 → P1 ...

This shows how execution order changes.


Conclusion

FCFS is simple but less efficient.
SJF gives the best average waiting time but may cause starvation.
RR is most suitable for multitasking and time-sharing systems because it gives equal chance to every process.

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

UNIT=4

Explain LRU Page Replacement (7 Marks – GTU Style)

LRU (Least Recently Used) Page Replacement is an important page replacement algorithm used in operating systems. It removes the page that has not been used for the longest time when a new page needs to be loaded into memory.

The main idea of LRU is that pages used recently are likely to be used again soon, so they should remain in memory.

LRU is more efficient than FIFO because it uses the history of page usage.


Definition

LRU page replacement is a technique in which the page that was least recently accessed is replaced first when memory is full.

It helps in reducing page faults and improving memory performance.


Working of LRU

The working of LRU is as follows:

1. Check whether the page is present in memory

  • If the page is found, it is called a Page Hit.

  • The page becomes the most recently used.

2. If the page is not present

  • A Page Fault occurs.

3. If there is an empty frame

  • The page is loaded into the empty frame.

4. If all frames are full

  • The operating system checks which page was used least recently.

5. Replace the least recently used page

  • That old page is removed.

  • The new page is inserted.

6. Continue execution

  • The process continues after page replacement.


Diagram of LRU

Reference Page Arrives
        |
        v
 Page Present?
   /      \
 Yes       No
 |          |
Hit       Page Fault
 |          |
Update   Empty Frame?
Usage     /      \
         Yes      No
          |        |
      Load Page   Replace LRU Page

Example (VDU Table)

Reference String: 7, 0, 1, 2, 0, 3, 0, 4
Number of Frames = 3

Page ReferenceFrame 1Frame 2Frame 3Status
77--Fault
070-Fault
1701Fault
2201Fault (7 removed)
0201Hit
3203Fault (1 removed)
0203Hit
4403Fault (2 removed)

Calculation

Total Pages = 8
Total Page Faults = 6
Total Page Hits = 2

Hit Ratio = Page Hits / Total Pages
= 2 / 8
= 0.25

Fault Ratio = Page Faults / Total Pages
= 6 / 8
= 0.75


Advantages of LRU

1. Reduces Page Faults

LRU gives fewer page faults than FIFO.

2. Better Memory Utilization

Frequently used pages stay in memory.

3. Improves Performance

System performance becomes better.

4. Uses Actual Page History

It makes better replacement decisions.


Disadvantages of LRU

1. Difficult to Implement

Tracking page usage is complex.

2. Extra Time Required

Updating recent use information takes time.

3. Extra Memory Needed

Additional data structures are required.


Difference between FIFO and LRU

BasisFIFOLRU
RuleFIFO removes the oldest page.LRU removes the least recently used page.
PerformanceFIFO gives more page faults.LRU gives fewer page faults.
ComplexityFIFO is simple.LRU is complex.
EfficiencyFIFO is less efficient.LRU is more efficient.

Conclusion

LRU page replacement is one of the best page replacement techniques in operating systems. It replaces the least recently used page, which helps reduce unnecessary page faults. Although its implementation is complex, it provides better performance and efficient memory management.

Explain First Fit, Best Fit and Worst Fit (7 Marks – GTU Style)

First Fit, Best Fit, and Worst Fit are memory allocation techniques used in operating systems for dynamic memory management.
When a process requests memory, the operating system uses these methods to allocate free memory blocks.

These methods help in efficient memory utilization.


1. First Fit

In First Fit, the operating system allocates the first free memory block that is large enough for the process.

It starts searching from the beginning of memory and stops when it finds the first suitable block.

Working:

  • Scan memory blocks from start.

  • Select the first block that fits the process size.

  • Allocate memory.

Example:

Free blocks: 100 KB, 500 KB, 200 KB, 300 KB, 600 KB
Process size = 212 KB

Allocation:

  • 100 KB → Not enough

  • 500 KB → Selected (first suitable block)

So process is allocated in 500 KB block.

Advantages:

  • Simple and fast.

  • Easy to implement.

Disadvantages:

  • Causes memory fragmentation.

  • May waste large blocks.


2. Best Fit

In Best Fit, the operating system allocates the smallest free block that is sufficient for the process.

It searches all memory blocks and selects the best matching block.

Working:

  • Check all free blocks.

  • Find the smallest suitable block.

  • Allocate memory.

Example:

Free blocks: 100 KB, 500 KB, 200 KB, 300 KB, 600 KB
Process size = 212 KB

Allocation:

  • Suitable blocks: 500, 300, 600

  • Smallest suitable = 300 KB

So process is allocated in 300 KB block.

Advantages:

  • Reduces memory wastage.

  • Uses memory efficiently.

Disadvantages:

  • Searching takes more time.

  • Creates many small unused blocks.


3. Worst Fit

In Worst Fit, the operating system allocates the largest available block to the process.

The idea is to leave large remaining space after allocation.

Working:

  • Check all free blocks.

  • Select the largest block.

  • Allocate memory.

Example:

Free blocks: 100 KB, 500 KB, 200 KB, 300 KB, 600 KB
Process size = 212 KB

Largest block = 600 KB

So process is allocated in 600 KB block.

Advantages:

  • Large leftover space remains.

  • Useful for future large processes.

Disadvantages:

  • Wastes large memory blocks.

  • Not efficient in many cases.


Comparison Table

BasisFirst FitBest FitWorst Fit
SelectionSelects first suitable block.Selects smallest suitable block.Selects largest suitable block.
SpeedIt is fast.It is slower.It is slower.
Memory UsageMay waste memory.Uses memory efficiently.May waste large memory.
FragmentationMore fragmentation occurs.Small fragments are created.Large fragments may remain.
SearchingStops early after finding block.Searches all blocks.Searches all blocks.

Conclusion

First Fit, Best Fit, and Worst Fit are important memory allocation methods.
First Fit is simple and fast.
Best Fit uses memory more efficiently.
Worst Fit keeps larger free blocks for future use.
The choice of method depends on system requirements.

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

UNIT=5

Directory Structure in Operating System (GTU Style – 7 Marks)

A directory structure is a way of organizing files and folders in an operating system. A directory is a special file that contains information about files and subdirectories. It helps users to store, manage, and access files easily.

Directory structure is important because an operating system stores a large number of files, and without proper organization it becomes difficult to manage them.


Definition

A directory structure is the hierarchical arrangement of files and directories in an operating system.


Need of Directory Structure

  • It organizes files properly.

  • It makes searching easy and fast.

  • It avoids confusion between files.

  • It provides security and protection.

  • It supports file sharing.

  • It improves file management.


Operations on Directory

The operating system performs different operations on directories for file management.

1. Create

  • Used to create a new directory.

  • Example: Creating a new folder named “Documents”.

2. Delete

  • Used to remove a directory.

  • A directory can be deleted only if it is empty (in many systems).

3. Open

  • Used to open a directory and access its files.

4. Close

  • Used to close the directory after work is completed.

5. Search

  • Used to find a file inside the directory.

6. Read

  • Used to read the contents of a directory.

7. Rename

  • Used to change the name of a directory.

8. Traverse

  • Used to move through all files and subdirectories.


Types of Directory Structure

1. Single-Level Directory Structure

In this structure, all files are stored in one single directory.

       Directory
     /   |   |   \
    A    B   C    D

Points:

  • Simplest directory structure.

  • No subdirectories are present.

  • All users store files in one place.

  • Each file name must be unique.

  • Suitable for small systems.

Advantages:

  • Easy to understand.

  • Easy to implement.

  • Fast for small number of files.

Disadvantages:

  • File name conflict occurs.

  • Difficult for large systems.

  • No grouping of files.


2. Two-Level Directory Structure

This structure contains one master directory and separate directories for each user.

        Master Directory
         /           \
     User1          User2
    / |  \          / |  \
   A  B   C        D  E   F

Points:

  • Each user has their own directory.

  • Same file names are allowed for different users.

  • Better organization than single-level.

  • User files are separated.

  • Searching is easier.

Advantages:

  • Avoids file name conflicts.

  • Better security.

  • Better management.

Disadvantages:

  • File sharing is difficult.

  • Limited flexibility.


3. Tree-Structured Directory

This structure contains root directory and subdirectories in hierarchical form.

            Root
          /   |   \
       Bin   Home  Docs
            /   \
         User1 User2

Points:

  • Starts from root directory.

  • Supports multiple levels.

  • Files can be grouped.

  • Most commonly used structure.

  • Easy navigation.

Advantages:

  • Better organization.

  • Easy searching.

  • Flexible and efficient.

Disadvantages:

  • More complex.

  • Requires proper management.


4. Acyclic Graph Directory Structure

In this structure, files and directories can be shared but cycles are not allowed.

        Root
       /    \
     Dir1   Dir2
       \    /
      Shared File

Points:

  • Supports file sharing.

  • Same file can appear in multiple directories.

  • No cycle formation.

  • Saves memory space.

  • Avoids duplication.

Advantages:

  • Easy sharing.

  • Saves storage space.

  • Better resource usage.

Disadvantages:

  • Complex structure.

  • Deletion problem may occur.


5. General Graph Directory Structure

This structure allows both file sharing and cycles.

A → B → C
↑       ↓
← ← ← ←

Points:

  • Directories can form cycles.

  • Maximum flexibility.

  • Supports advanced sharing.

  • Complex structure.

  • Needs special handling.

Advantages:

  • Maximum sharing.

  • Very flexible.

Disadvantages:

  • Infinite loop problem.

  • Difficult searching.

  • Hard to manage.


Conclusion

Directory structure is an important part of the operating system. It helps to organize files and perform operations like create, delete, search, and rename. Different types of directory structures are used depending on system requirements. Among them, Tree-Structured Directory is the most commonly used because it provides better organization and flexibility.

Q.Explain Boot Block with advantages and disadvantages. (GTU Style – Long Answer – 7 Marks)

A Boot Block is a special block present at the beginning of a disk. It contains a small program called the bootstrap loader which is used to start the computer system and load the operating system into main memory.

When the computer is switched ON, the system first checks hardware and then reads the boot block from the disk. The boot block then loads the operating system kernel into memory and starts execution.

It is the most important part of the booting process because without it the operating system cannot start.


Definition

A Boot Block is the first block of the storage device that stores the bootstrap program required to load the operating system.


Need of Boot Block

  • It starts the computer system.

  • It loads the operating system into memory.

  • It connects hardware initialization with OS loading.

  • It makes the booting process automatic.

  • It provides initial instructions to the CPU.


Working of Boot Block

The boot block works in the following steps:

1. Power ON

  • The computer is switched ON.

2. BIOS/UEFI Starts

  • BIOS or UEFI checks all hardware devices.

  • This checking process is called POST (Power-On Self Test).

3. Search Boot Device

  • BIOS searches for a bootable device such as HDD, SSD, or USB.

4. Load Boot Block

  • The first block of the bootable disk is loaded into memory.

5. Execute Bootstrap Loader

  • The bootstrap program stored in the boot block starts execution.

6. Load Operating System

  • The bootstrap loader loads the operating system kernel into RAM.

7. System Ready

  • The operating system takes control and the system becomes ready.


Diagram of Boot Block

        Power ON
           ↓
      BIOS / UEFI
           ↓
   Search Boot Device
           ↓
      Load Boot Block
           ↓
 Execute Bootstrap Loader
           ↓
      Load OS Kernel
           ↓
      System Ready

Characteristics of Boot Block

  • It is located at the beginning of the disk.

  • It contains bootstrap code.

  • It is small in size.

  • It is necessary for system startup.

  • It loads the operating system.


Advantages of Boot Block

  • Automatic system startup

  • Fast loading of operating system

  • Easy and organized booting process

  • Connects BIOS with operating system

  • Supports different bootable devices

  • Necessary for system initialization


Disadvantages of Boot Block

  • System cannot start if corrupted

  • Small storage capacity

  • Vulnerable to boot sector viruses

  • Difficult recovery process

  • Depends completely on storage device

  • Security risks due to unauthorized changes


Applications of Boot Block

  • Hard Disk Drive (HDD)

  • Solid State Drive (SSD)

  • USB Drive

  • CD/DVD

  • Memory Card

  • Network Boot (PXE)


Explain Bad Block with Causes and Types (GTU Style – Long Answer – 7 Marks)

A Bad Block is a block or sector in a storage device that cannot be used for storing or reading data correctly. It is a defective area of the disk where data may become corrupted or inaccessible.

In operating systems, storage devices such as hard disks, SSDs, USB drives, and memory cards are divided into many small blocks. These blocks are used to store data. If any block becomes damaged or corrupted, it is called a Bad Block.

Bad blocks can affect system performance and may lead to loss of important data. Therefore, the operating system detects such blocks and marks them so they are not used again.


Definition

A Bad Block is a damaged or corrupted block in secondary storage that cannot perform read or write operations properly.


Need of Bad Block Management

Bad block management is necessary because:

  • It prevents data loss.

  • It improves storage reliability.

  • It avoids using damaged blocks.

  • It protects important files.

  • It improves disk performance.


Causes of Bad Block

There are many causes of bad blocks:

1. Physical Damage

  • Damage to the disk surface due to scratches or shock can create bad blocks.

2. Sudden Power Failure

  • If power fails during writing, the block may become corrupted.

3. Improper Shutdown

  • Force shutdown can damage file system blocks.

4. Aging of Storage Device

  • After long use, storage media may wear out.

5. Virus or Malware Attack

  • Viruses can corrupt data and create bad blocks.

6. Manufacturing Defect

  • Some storage devices may contain defective blocks from the beginning.

7. Excessive Heat

  • High temperature can damage the internal components.

8. Repeated Read/Write Operations

  • Frequent usage may reduce the life of storage blocks.


Types of Bad Block

Bad blocks are mainly divided into two types:


1. Physical Bad Block (Hard Bad Block)

A Physical Bad Block is created due to actual physical damage in the storage device. It is also called a hard bad block.

Disk Surface
--------------------
| Good | Bad | Good |
--------------------

Points:

  • It occurs because of hardware damage.

  • It is permanent in nature.

  • It cannot be repaired.

  • The operating system marks it as unusable.

  • Data stored in it may be permanently lost.

Example:

A damaged sector on a hard disk because of falling or scratching.

Advantages:

  • Helps the OS identify damaged sectors.

  • Prevents reuse of defective blocks.

Disadvantages:

  • Permanent data loss.

  • Reduces storage capacity.


2. Logical Bad Block (Soft Bad Block)

A Logical Bad Block occurs because of software errors or incorrect data writing. It is also called a soft bad block.

Data Error
--------------------
| Good | Error | Good |
--------------------

Points:

  • It occurs due to software or file system problems.

  • There is no physical damage.

  • It can be repaired using disk tools.

  • It is temporary in many cases.

  • Data may be recoverable.

Example:

Corrupted data after sudden shutdown.

Advantages:

  • Can be repaired.

  • Data can sometimes be recovered.

Disadvantages:

  • May affect system performance.

  • Can cause temporary data access problems.


Detection of Bad Blocks

The operating system can detect bad blocks using:

1. Disk Scanning

  • Checks all sectors of the disk.

2. Error Checking Tools

  • Tools like CHKDSK and fsck.

3. SMART Monitoring

  • Monitors disk health automatically.

4. Read/Write Testing

  • Detects errors during operations.


Prevention of Bad Blocks

Bad blocks can be reduced by:

  • Proper shutdown of the system.

  • Using UPS to avoid power failure.

  • Regular disk scanning.

  • Protecting storage from heat and shock.

  • Keeping antivirus updated.

  • Taking regular backups.


Applications / Where Bad Blocks are Found

  • Hard Disk Drive (HDD)

  • Solid State Drive (SSD)

  • USB Drive

  • Memory Card

  • CD/DVD

  • External Hard Disk


UNIT:2

Explain Mutual Exclusion in Operating System. (GTU Style – 7 Marks)

Mutual Exclusion

Mutual Exclusion is a synchronization technique used in an operating system to ensure that only one process can access a shared resource at a time.

It allows only one process to enter the critical section at a time. If one process is executing in the critical section, other processes must wait.

The main purpose of mutual exclusion is to prevent race condition and maintain data consistency.


Need of Mutual Exclusion

When many processes share the same resource like memory, file, or printer, problems may occur if they access it together.

For example:

Suppose two processes P1 and P2 want to update the same variable.

  • Value of X = 10

  • P1 adds 5

  • P2 adds 10

If both execute at the same time, the final result may be wrong.

So, mutual exclusion is required.


Real Life Example (Bank Transaction)

Consider a bank account with balance ₹10,000.

Two transactions happen at the same time:

  • P1 wants to withdraw ₹2,000
  • P2 wants to withdraw ₹3,000

Without mutual exclusion:

  • P1 reads balance = ₹10,000
  • P2 also reads balance = ₹10,000
  • P1 updates balance = ₹8,000
  • P2 updates balance = ₹7,000

Final balance becomes ₹7,000, but the correct balance should be ₹5,000.

This problem happens because both processes access the same data at the same time.

With mutual exclusion:

  • P1 enters critical section and withdraws ₹2,000
  • P2 waits outside
  • After P1 finishes, P2 enters and withdraws ₹3,000

Final balance becomes ₹5,000, which is correct.

This shows why mutual exclusion is necessary.


Basic Structure of Critical Section

do{
   Entry Section
   Critical Section
   Exit Section
   Remainder Section
} while(TRUE);

1. Entry Section

In this section, the process requests permission to enter the critical section.

2. Critical Section

This section contains the code where shared resources are accessed.

3. Exit Section

After completing work, the process leaves the critical section.

4. Remainder Section

This is the remaining part of the program.


Requirements of Mutual Exclusion

A good mutual exclusion solution must satisfy the following conditions:

1. Mutual Exclusion

Only one process can enter the critical section at one time.

2. Progress

If no process is inside the critical section, waiting processes should be allowed to enter.

3. Bounded Waiting

Every process should get a chance after a limited waiting time.


Methods of Mutual Exclusion

1. Software Solutions

These methods use programming logic.

Examples:

  • Peterson’s Algorithm

  • Dekker’s Algorithm


2. Hardware Solutions

These methods use special CPU instructions.

Examples:

  • Test and Set

  • Compare and Swap


3. Semaphore

Semaphore is a signaling mechanism used for process synchronization.

It controls access to shared resources.


4. Mutex Lock

Mutex is a locking mechanism.

A process locks the resource before using it and unlocks after completing.


Advantages of Mutual Exclusion

  • It prevents race condition.

  • It protects shared data.

  • It maintains data consistency.

  • It provides proper synchronization.


Disadvantages of Mutual Exclusion

  • It may create deadlock.

  • It increases waiting time.

  • It can reduce system performance.


Applications of Mutual Exclusion

  • Printer sharing

  • File management

  • Database systems

  • Banking transactions

  • Shared memory access




 OTHER QUE.

4. Compare Pre-emptive and Non-Preemptive Scheduling

Introduction

CPU Scheduling is the process of selecting a process from the ready queue and allocating the CPU for execution. Scheduling algorithms are mainly classified into Pre-emptive and Non-Preemptive scheduling.


Pre-emptive Scheduling

In Pre-emptive Scheduling, the operating system can take the CPU away from a running process and assign it to another process. This usually happens when a higher-priority process arrives or when the time quantum expires.

Examples

  • Round Robin (RR)

  • Shortest Remaining Time First (SRTF)

  • Pre-emptive Priority Scheduling

Advantages

  • Better response time.

  • Suitable for interactive and time-sharing systems.

  • High-priority processes get CPU quickly.

Disadvantages

  • More context switching overhead.

  • More complex to implement.


Non-Preemptive Scheduling

In Non-Preemptive Scheduling, once a process gets the CPU, it continues execution until it finishes or enters a waiting state. The CPU cannot be taken away forcibly.

Examples

  • FCFS (First Come First Serve)

  • SJF (Non-Preemptive)

  • Non-Preemptive Priority Scheduling

Advantages

  • Simple and easy to implement.

  • Less context switching overhead.

  • Efficient for batch systems.

Disadvantages

  • Poor response time.

  • Long processes may keep the CPU for a long time.


Comparison Between Pre-emptive and Non-Preemptive Scheduling

Pre-emptive SchedulingNon-Preemptive Scheduling
CPU can be taken away from a running process.CPU cannot be taken away until the process completes.
More flexible and responsive.Less responsive.
Suitable for time-sharing systems.Suitable for batch processing systems.
Requires more context switching.Requires less context switching.
More complex to implement.Easy to implement.
Better response time.Higher response time.
Examples: Round Robin, SRTF.Examples: FCFS, SJF.
Higher overhead due to frequent switching.Lower overhead.

Conclusion

Pre-emptive scheduling allows the operating system to interrupt a running process and allocate the CPU to another process, resulting in better responsiveness. Non-Preemptive scheduling allows a process to run until completion, making it simpler and less costly. The choice between them depends on the requirements of the system.


UNIT=2

1. Explain Synchronization Problems in Operating Systems.

Introduction

In a multiprogramming operating system, multiple processes may execute simultaneously and share common resources such as memory, files, and printers. When several processes access shared data at the same time, inconsistencies may occur. To avoid such problems, process synchronization is required.

Synchronization is a technique used to coordinate the execution of multiple processes so that shared resources are accessed safely and correctly.


Need for Synchronization

  • To prevent data inconsistency.

  • To avoid race conditions.

  • To ensure mutual exclusion.

  • To maintain correct execution of processes.

  • To protect shared resources from simultaneous access.


Common Synchronization Problems

1. Producer-Consumer Problem (Bounded Buffer Problem)

In this problem, one process (Producer) produces data and places it into a buffer, while another process (Consumer) removes data from the buffer.

Problem

  • Producer should not add data if the buffer is full.

  • Consumer should not remove data if the buffer is empty.

Diagram

Producer ---> Buffer ---> Consumer

Solution

  • Use Semaphores and Mutual Exclusion.

  • Producer waits when the buffer is full.

  • Consumer waits when the buffer is empty.

Example

A keyboard (producer) generates characters and stores them in a buffer, while a program (consumer) reads those characters.


2. Readers-Writers Problem

In this problem, multiple readers and writers share a common database.

Problem

  • Multiple readers can read the database simultaneously.

  • Only one writer can write at a time.

  • No reader should read while a writer is updating data.

Diagram

Readers ----\
             > Shared Database
Writers ----/

Solution

  • Allow multiple readers together.

  • Allow only one writer at a time using synchronization techniques.

Example

Students reading records from a library database while a librarian updates records.


3. Dining Philosophers Problem

This classical synchronization problem involves five philosophers sitting around a circular table.

Problem

  • Each philosopher alternates between thinking and eating.

  • To eat, a philosopher needs two forks.

  • If all philosophers pick one fork at the same time, deadlock occurs.

Diagram

      P1
   /      \
 P5        P2
 |          |
 P4        P3

(Forks are placed between philosophers.)

Solution

  • Use Semaphores.

  • Limit the number of philosophers allowed to eat simultaneously.

  • Prevent deadlock by proper resource allocation.

Example

Five people sharing limited resources such as printers or network connections.


Race Condition

A Race Condition occurs when two or more processes access and modify shared data simultaneously, and the final result depends on the order of execution.

Example

Suppose variable X = 10.

Process P1: X = X + 5

Process P2: X = X - 3

If both execute simultaneously, the final value may become incorrect.

Solution

Use synchronization mechanisms such as:

  • Mutex Locks

  • Semaphores

  • Monitors


Synchronization Tools

1. Semaphore

A semaphore is a signaling mechanism used to control access to shared resources.

2. Mutex

A mutex allows only one process to access a critical section at a time.

3. Monitor

A monitor is a high-level synchronization construct that provides mutual exclusion automatically.


Advantages of Synchronization

  1. Prevents data inconsistency.

  2. Avoids race conditions.

  3. Ensures mutual exclusion.

  4. Improves system reliability.

  5. Provides proper sharing of resources.


Conclusion

Synchronization is an important concept in operating systems that coordinates multiple processes accessing shared resources. Common synchronization problems include the Producer-Consumer Problem, Readers-Writers Problem, and Dining Philosophers Problem. These problems are solved using techniques such as Semaphores, Mutexes, and Monitors, ensuring correct and efficient process execution.

CN_IMP_CH:4

 

1. Explain Shortest Path Routing Algorithm. (GTU Style – Long Answer)

Definition:

The Shortest Path Routing Algorithm is a routing technique used in computer networks to find the minimum cost path between source and destination.
It helps the router choose the best path for sending data packets.

The shortest path can be based on:

  • Minimum distance

  • Minimum delay

  • Minimum number of hops

  • Minimum cost

Its main goal is to improve speed and reduce network traffic.


Basic Idea:

In this algorithm, the network is represented as a graph.

  • Router/Computer = Node (Vertex)

  • Connection between routers = Link (Edge)

  • Value assigned to link = Cost (Weight)

The router calculates all possible paths and selects the path with the lowest cost.


Working of Shortest Path Routing Algorithm:

The working is as follows:

1. Create Network Graph

The entire network is shown as a graph where nodes are connected by links.

2. Assign Cost to Each Link

Each link has a cost value like distance or delay.

Example:

  • Smaller cost = better path

  • Larger cost = longer path

3. Select Source Node

The starting node is selected.

4. Calculate Path Cost

The algorithm checks all possible routes from source to destination.

5. Choose Minimum Cost Path

The path having the smallest total cost is selected.

6. Send Data

Data packets are sent through that selected shortest path.


Steps of Shortest Path Algorithm:

  1. Start from source node.

  2. Set source node cost = 0.

  3. Set all other node costs = ∞ (infinity).

  4. Select the nearest unvisited node.

  5. Update cost of neighboring nodes.

  6. Mark current node as visited.

  7. Repeat until destination is reached.


Example:

Consider the following network:

        2
   A ------- B
   |         |
   |4       3|
   |         |
   C ------- D
        1

Find shortest path from A to D

Possible paths:

Path 1:

A → B → D
Cost = 2 + 3 = 5

Path 2:

A → C → D
Cost = 4 + 1 = 5

Both paths have equal cost.

So shortest path = 5

Router can choose any one.


Algorithms used in Shortest Path Routing:

1. Dijkstra’s Algorithm

  • Most commonly used

  • Finds shortest path from one source to all nodes

  • Used in many routing protocols

2. Bellman-Ford Algorithm

  • Used when network changes frequently

  • Can handle changing costs


Advantages:

1. Efficient Routing

Finds best path quickly.

2. Less Delay

Data reaches destination faster.

3. Better Performance

Improves network speed.

4. Saves Bandwidth

Avoids unnecessary long routes.

5. Reliable Communication

Helps in proper packet delivery.


Disadvantages:

1. More Calculation

Needs continuous cost calculation.

2. Complex for Large Network

Difficult when network size increases.

3. More Memory Required

Stores routing tables.

4. Recalculation Needed

If network changes, path must be recalculated.


Conclusion:

Shortest Path Routing Algorithm is one of the most important routing methods in computer networks. It helps in selecting the best and lowest cost path for packet transmission. It increases speed, reduces delay, and improves overall network efficiency.

2. Explain Distance Vector Routing Algorithm. (GTU Style – Long & Easy)

Definition:

Distance Vector Routing Algorithm is a routing algorithm in which every router maintains a routing table that stores the distance and direction to reach all other nodes in the network.

It is called:

  • Distance → Shows how far the destination is.

  • Vector → Shows in which direction (next router) to send the packet.

In simple words, each router tells its neighbors:
“How far I am from all destinations.”

This helps routers find the shortest path.


Basic Concept:

In this algorithm:

  • Every router knows only about its direct neighbors.

  • Each router keeps a routing table.

  • Routers exchange their routing tables with neighbors regularly.

  • After receiving information, routers update their own tables.

This process continues until all routers get the best path.

This is called convergence.


Routing Table Contains:

Each routing table has:

DestinationDistanceNext Hop
A0-
B2B
C5B

Where:

  • Destination = final node

  • Distance = cost to reach

  • Next hop = next router


Working of Distance Vector Routing:

The working of this algorithm is as follows:

1. Initial Table Creation

Each router creates its routing table.

It knows:

  • Its own distance = 0

  • Direct neighbor distance = actual cost

  • Other nodes = infinity (∞)


2. Share Routing Table

Each router sends its table to all neighboring routers.

This sharing happens periodically.


3. Receive Neighbor Information

Router receives routing tables from neighbors.

Now it gets information about other possible routes.


4. Compare Path Cost

Router checks:

New cost = Neighbor cost + Link cost

If new cost is smaller, update the table.


5. Update Routing Table

Router changes:

  • Distance

  • Next hop

if better path is found.


6. Repeat Process

This process continues until no more changes occur.

That means shortest path is found.


Easy Steps of Distance Vector Algorithm:

  1. Each router knows only direct neighbors.

  2. Create initial routing table.

  3. Send table to neighbors.

  4. Receive neighbor tables.

  5. Compare costs.

  6. Update if shorter path is found.

  7. Repeat until all best paths are fixed.


Example:

Consider this network:

A ----1---- B ----2---- C

Initial routing table:

Router A:

DestinationCost
A0
B1
C

Router B:

DestinationCost
A1
B0
C2

After B shares its table:

A learns:

To reach C through B:

A → B → C

Cost = 1 + 2 = 3

So A updates:

DestinationCost
C3

Now A can reach C.


Formula Used:

New Distance = Distance to Neighbor + Neighbor’s Distance to Destination

Example:

A to B = 2
B to C = 4

Then:

A to C = 2 + 4 = 6


Advantages:

1. Simple to Implement

Easy to understand and use.

2. Less Complex

Works with simple calculations.

3. Automatic Route Updates

Routes update automatically.

4. Good for Small Networks

Efficient in small-size networks.

5. Low Processing Power

Requires less CPU power.


Disadvantages:

1. Slow Convergence

Takes more time to update all routers.

2. Routing Loops

Packets may move in circles.

3. Count to Infinity Problem

Wrong route information may spread.

4. More Traffic

Frequent routing updates increase traffic.

5. Not Suitable for Large Networks

Performance becomes poor.


Example of Protocol:

The best example of Distance Vector Routing is:

  • RIP (Routing Information Protocol)

RIP uses this algorithm.

Maximum hop count in RIP = 15


Conclusion:

Distance Vector Routing Algorithm is a simple and important routing technique in computer networks. It works by exchanging routing tables with neighbors and finding the shortest path. It is easy to use but slower for large networks.


3. Explain Link State Routing. (GTU Style – Long & Easy)

Definition:

Link State Routing is a routing algorithm in which each router collects complete information about the network and calculates the shortest path by itself.

In this method, every router knows the full network topology.

Unlike Distance Vector Routing, routers do not send the whole routing table.
They send only the state of their links.

Link state means:

  • Which neighbors are connected

  • What is the cost of each link

This helps in finding the best route quickly.


Basic Concept:

In Link State Routing:

  • Each router creates information about its directly connected links.

  • This information is sent to all routers in the network.

  • Every router builds the same network map.

  • Then each router uses the shortest path algorithm to find best route.

Most commonly it uses Dijkstra's algorithm.


Working of Link State Routing:

The working is as follows:

1. Discover Neighbors

Each router finds its directly connected neighboring routers.


2. Measure Link Cost

Router calculates cost like:

  • Distance

  • Delay

  • Bandwidth


3. Create Link State Packet (LSP)

Router prepares a packet containing:

  • Router ID

  • Neighbor list

  • Cost of each link


4. Flood LSP to All Routers

The LSP is sent to all routers in the network.

This process is called flooding.


5. Build Network Topology

Each router collects all LSPs and creates a complete network map.


6. Calculate Shortest Path

Each router uses Dijkstra’s Algorithm to find shortest path.


7. Update Routing Table

Finally, router stores best path in routing table.


Easy Steps of Link State Routing:

  1. Find neighboring routers.

  2. Measure link cost.

  3. Create Link State Packet (LSP).

  4. Send LSP to all routers.

  5. Build network map.

  6. Apply shortest path algorithm.

  7. Store best route in routing table.


Example:

Consider network:

A ----2---- B
|           |
4           3
|           |
C ----1---- D

Suppose router A sends:

  • A to B = 2

  • A to C = 4

Other routers also send their LSPs.

Now every router builds the full map.

Using Dijkstra:

From A to D:

Path 1: A → B → D = 2 + 3 = 5
Path 2: A → C → D = 4 + 1 = 5

Shortest path cost = 5


Link State Packet (LSP) Contains:

  • Source router ID

  • Sequence number

  • Age

  • Neighbor list

  • Link cost


Advantages:

1. Fast Convergence

Updates quickly.

2. No Routing Loops

More reliable.

3. Better for Large Networks

Works efficiently in large networks.

4. Accurate Routing

Complete network information gives better decisions.

5. Less Unnecessary Traffic

Only link changes are sent.


Disadvantages:

1. Complex Algorithm

More difficult than Distance Vector.

2. More Memory Needed

Stores full network map.

3. High CPU Usage

Calculates shortest path frequently.

4. Flooding Overhead

LSP flooding creates extra load.


Example of Protocol:

The best example of Link State Routing is:

  • OSPF (Open Shortest Path First)

OSPF uses Link State Routing.


Difference from Distance Vector:

Link StateDistance Vector
Sends link informationSends full routing table
FasterSlower
No loopsLoops possible
More complexSimpler

4. Explain Congestion Control. (GTU Style – Long & Easy)

Definition:

Congestion Control is a technique used in computer networks to control the amount of data entering the network so that the network does not become overloaded.

Congestion happens when too many packets are sent at the same time and the network cannot handle them.

This causes:

  • Delay in packet delivery

  • Packet loss

  • Slow network performance

Congestion control helps to reduce these problems.


What is Congestion?

Congestion means the network is carrying more data than its capacity.

It happens when:

Incoming packets > Processing capacity

Example:

If a router can process 100 packets/sec but receives 200 packets/sec, congestion occurs.


Need of Congestion Control:

Congestion control is important because:

1. To avoid packet loss

Too many packets may be dropped.

2. To reduce delay

Packets can reach faster.

3. To improve network performance

Network works smoothly.

4. To use bandwidth properly

Avoids unnecessary traffic.


Causes of Congestion:

1. High Traffic Load

Many users sending data together.

2. Slow Routers

Router cannot process data fast.

3. Limited Bandwidth

Small capacity causes overload.

4. Retransmission of Lost Packets

Lost packets increase traffic.

5. Poor Network Design

Improper routing may create congestion.


Working of Congestion Control:

The working is:

1. Detect Congestion

Network checks if traffic is increasing.


2. Inform Sender

Receiver/router informs sender about congestion.


3. Reduce Sending Rate

Sender decreases speed of sending packets.


4. Recover Network

After traffic becomes normal, speed increases.


Methods of Congestion Control:

There are mainly two methods:


1. Open Loop Congestion Control

This method tries to prevent congestion before it happens.

It does not use feedback.

Techniques:

a) Retransmission Policy

Controls unnecessary retransmissions.

b) Window Policy

Uses proper window size.

c) Acknowledgement Policy

Reduces extra acknowledgements.

d) Discarding Policy

Drops less important packets.

e) Admission Policy

Checks network load before accepting data.


2. Closed Loop Congestion Control

This method detects congestion and takes action.

It uses feedback.

Techniques:

a) Backpressure

Router informs previous router to slow down.

b) Choke Packet

Router sends warning packet to sender.

c) Implicit Signaling

Sender guesses congestion by delay or loss.

d) Explicit Signaling

Network directly informs sender.


Example:

Suppose:

  • Router capacity = 50 packets/sec

  • Incoming packets = 90 packets/sec

Since 90 > 50

Congestion occurs.

Router sends signal to sender.

Sender reduces speed.

Traffic becomes normal.


Effects of Congestion:

1. Packet Loss

Packets may be dropped.

2. Increased Delay

Delivery becomes slow.

3. Low Throughput

Less data reaches destination.

4. Wastage of Bandwidth

Retransmissions waste bandwidth.


Advantages of Congestion Control:

1. Better network performance

2. Less packet loss

3. Faster communication

4. Proper bandwidth usage

5. Stable network operation


Disadvantages:

1. Extra control mechanisms needed

2. May reduce transmission speed

3. More complexity in network

Q.5 Explain TCP Three-Way Handshake for Connection Establishment.

Definition

TCP Three-Way Handshake is a process used by the Transmission Control Protocol (TCP) to establish a reliable connection between a client and a server before data transmission begins. It ensures that both devices are ready to communicate and synchronizes their sequence numbers.


Purpose of TCP Three-Way Handshake

  • Establishes a reliable connection.

  • Synchronizes sequence numbers between client and server.

  • Confirms that both devices are ready for communication.

  • Prevents data loss during connection setup.


Working of TCP Three-Way Handshake

The connection establishment process consists of three steps:

Step 1: SYN (Synchronize)

The client sends a SYN packet to the server requesting a connection.

Client  -------- SYN -------->  Server

This packet contains the client's initial sequence number.


Step 2: SYN-ACK (Synchronize Acknowledgment)

The server receives the SYN packet and responds with a SYN-ACK packet.

Client  <----- SYN + ACK -----  Server
  • SYN indicates the server is ready to communicate.

  • ACK acknowledges the client's request.


Step 3: ACK (Acknowledgment)

The client sends an ACK packet to the server.

Client  -------- ACK -------->  Server

After receiving this ACK, the server knows that the client is ready and the connection is established.


Diagram



Example

Suppose a user opens a website in a browser.

  1. The browser (client) sends a SYN packet to the web server.

  2. The web server responds with a SYN-ACK packet.

  3. The browser sends an ACK packet.

  4. The TCP connection is established.

  5. The server starts sending the requested web page data.


Advantages

  1. Provides reliable communication.

  2. Ensures both sides are ready before data transfer.

  3. Synchronizes sequence numbers.

  4. Reduces the chances of communication errors.


Disadvantages

  1. Requires extra time for connection setup.

  2. Generates additional network traffic.

  3. Slightly increases communication overhead.


Conclusion

TCP Three-Way Handshake is the connection establishment process used by TCP. It consists of three steps: SYN, SYN-ACK, and ACK. This process creates a reliable connection between the client and server, ensuring accurate and secure data transmission.

6. Explain Transport Service Primitives. (GTU Style – Long & Easy)

Definition:

Transport Service Primitives are the basic operations provided by the transport layer to establish communication between sender and receiver.

These primitives help in:

  • Establishing connection

  • Sending data

  • Receiving data

  • Disconnecting connection

In simple words, transport service primitives are commands used for communication between two devices.

The transport layer provides these services to the application layer.


Need of Transport Service Primitives:

They are needed to:

  • Start communication

  • Transfer data properly

  • Control connection

  • End communication safely

Without these primitives, communication would not be organized.


Main Transport Service Primitives:

There are mainly five transport service primitives:


1. LISTEN

This primitive is used by the server to wait for a connection request.

It means:

"I am ready to accept connection."

Example:
A web server waits for client request.

Function:

  • Waits for incoming connection

  • Keeps server ready


2. CONNECT

This primitive is used by the client to establish connection with server.

It means:

"I want to connect."

Example:
A client sends request to server.

Function:

  • Starts communication

  • Creates connection


3. SEND

This primitive is used to send data.

After connection establishment, sender uses SEND.

It means:

"Send this data."

Example:
Sending a message or file.

Function:

  • Transfers data from sender to receiver


4. RECEIVE

This primitive is used to receive data.

Receiver uses RECEIVE to accept data.

It means:

"Receive incoming data."

Example:
Receiving email or message.

Function:

  • Collects incoming data


5. DISCONNECT

This primitive is used to close the connection.

After data transfer is complete, DISCONNECT ends communication.

It means:

"Communication finished."

Function:

  • Terminates connection

  • Releases resources


Sequence of Transport Service Primitives:

The communication process follows:

Server Side                Client Side

LISTEN   <--------->   CONNECT
RECEIVE  <--------->   SEND
DISCONNECT <------->   DISCONNECT

Flow:

  1. Server waits using LISTEN

  2. Client starts using CONNECT

  3. Client sends data using SEND

  4. Server gets data using RECEIVE

  5. Both close connection using DISCONNECT


Example:

Suppose you open a website:

Step 1:

Server uses LISTEN.

Step 2:

Browser uses CONNECT.

Step 3:

Browser sends request using SEND.

Step 4:

Server receives request using RECEIVE.

Step 5:

After response, connection closes using DISCONNECT.


Advantages:

1. Organized Communication

Makes communication systematic.

2. Easy Connection Handling

Easy to establish and close connection.

3. Reliable Data Transfer

Ensures proper sending and receiving.

4. Better Resource Management

Releases resources after communication.


Disadvantages:

1. Extra Time for Connection Setup

2. More Control Operations

3. Slightly Complex Process


Conclusion:

Transport Service Primitives are essential functions of the transport layer that help establish, manage, transfer, and terminate communication between sender and receiver. They make communication reliable and organized in a network.

7. Differentiate UDP and TCP. (GTU Style – Long & Easy)

Introduction:

Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are transport layer protocols used for communication in computer networks.

Both are used to send data from one device to another, but their working is different.

  • TCP provides reliable communication.
  • UDP provides fast communication.

>TCP (Transmission Control Protocol)

TCP is a connection-oriented protocol.

It establishes connection before sending data.

Example:

  • Web browsing
  • Email
  • File transfer

>UDP (User Datagram Protocol)

UDP is a connectionless protocol.

It sends data directly without establishing connection.

Example:

  • Video streaming
  • Online gaming
  • Voice calls

Difference between Transmission Control Protocol (TCP) and User Datagram Protocol (UDP):

TCPUDP

TCP stands for Transmission Control Protocol.

UDP stands for User Datagram Protocol.

TCP is a connection-oriented protocol because it establishes connection before sending data.

UDP is a connectionless protocol because it sends data without establishing connection.

TCP provides reliable data transfer.

UDP provides unreliable data transfer.

In TCP, data packets are delivered in the correct order.
In UDP, data packets may not be delivered in order.

TCP uses acknowledgements to confirm packet delivery.
UDP does not use acknowledgements for packet delivery.

TCP is slower because it performs more checking and control.
UDP is faster because it has less control and overhead.

TCP has a larger header size of 20 bytes.
UDP has a smaller header size of 8 bytes.

TCP provides error checking and retransmits lost packets.
UDP only checks errors but does not retransmit lost packets.

TCP provides flow control to manage data transfer speed.
UDP does not provide flow control.

TCP provides congestion control to avoid network overload.
UDP does not provide congestion control.

TCP is suitable for applications like file transfer, email, and web browsing.
UDP is suitable for applications like video streaming, gaming, and voice calls.

TCP is more secure and reliable for important data transfer.
UDP is mainly used where speed is more important than reliability.

Example:

TCP Example:

When downloading a file:

If one packet is lost, TCP sends it again.

So data remains complete.


UDP Example:

In video call:

If one packet is lost, it is ignored.

Because speed is more important than perfect delivery.

8. Difference between Error Control and Flow Control. (GTU Style – Long & Easy)

Introduction:

Both Error Control and Flow Control are important mechanisms in computer networks.
They help in reliable data transmission between sender and receiver.

But their purpose is different:

  • Error Control checks and corrects errors in data.

  • Flow Control controls the speed of data transfer.


Difference between Error Control and Flow Control:

Error ControlFlow Control
Error control is a technique used to detect and correct errors during data transmission.

Flow control is a technique used to control the rate of data transmission between sender and receiver.
Its main purpose is to ensure that data is received correctly without errors.Its main purpose is to ensure that the sender does not send data faster than the receiver can handle.

It deals with damaged, lost, or duplicate packets.
It deals with matching the speed of sender and receiver.

Error control improves the reliability of communication.
Flow control improves the efficiency of communication.

It uses methods like error detection and retransmission.
It uses methods like stop-and-wait and sliding window.

If an error is found, the sender retransmits the data.
If receiver is busy, flow control slows down the sender.

It mainly focuses on data correctness.
It mainly focuses on data speed management.

Error control is related to reliability of data transfer.
Flow control is related to controlling data traffic.

Example: Lost packet is sent again.
Example: Sender waits if receiver is slow.

Example:

Error Control Example:

If a packet gets damaged during transmission, error control detects it and sends it again.


Flow Control Example:

If the sender sends data too fast and the receiver cannot process it, flow control tells sender to slow down.


9. Explain Connection Establishment and Connection Release. (GTU Style – Long & Easy)

Introduction:

In computer networks, before data transfer starts, a connection must be established between sender and receiver.
After communication is completed, that connection must be released.

This process is handled by the transport layer.

Connection management has two parts:

  1. Connection Establishment

  2. Connection Release

These are important for reliable communication.


1. Connection Establishment

Definition:

Connection Establishment is the process of creating a connection between sender and receiver before sending data.

It ensures that both sides are ready for communication.

This process is mainly used in Transmission Control Protocol (TCP).


Need of Connection Establishment:

It is needed to:

  • Make sure receiver is ready

  • Synchronize communication

  • Allocate resources

  • Start reliable data transfer


Three-Way Handshake (Connection Establishment)

TCP uses the Three-Way Handshake method.

It has three steps:


Step 1: SYN

Sender sends a SYN (synchronize) message to receiver.

It means:

"I want to start communication."


Step 2: SYN + ACK

Receiver sends SYN + ACK.

It means:

"I am ready and I received your request."


Step 3: ACK

Sender sends ACK.

It means:

"Connection confirmed."

Now connection is established.


Diagram of Connection Establishment:

Sender                         Receiver

SYN       -------------------->
          <-------------------- SYN + ACK
ACK       -------------------->

Connection Established

2. Connection Release

Definition:

Connection Release is the process of terminating the connection after data transfer is completed.

It frees network resources.


Need of Connection Release:

It is needed to:

  • End communication properly

  • Free memory and resources

  • Avoid unnecessary connection


Four-Way Handshake (Connection Release)

TCP uses Four-Way Handshake.

It has four steps:


Step 1: FIN

Sender sends FIN (finish).

It means:

"I have finished sending data."


Step 2: ACK

Receiver sends ACK.

It means:

"I received your finish request."


Step 3: FIN

Receiver sends its own FIN.

It means:

"I have also finished."


Step 4: ACK

Sender sends final ACK.

Connection is closed.


Diagram of Connection Release:

Sender                         Receiver

FIN       -------------------->
          <-------------------- ACK
          <-------------------- FIN
ACK       -------------------->

Connection Released

Advantages of Connection Establishment and Release:

1. Reliable Communication

Ensures proper connection before data transfer.

2. Proper Resource Management

Resources are allocated and released correctly.

3. Safe Termination

Connection ends without data loss.

4. Better Synchronization

Both sender and receiver stay coordinated.


Disadvantages:

1. Takes Extra Time

Connection setup and release need extra steps.

2. More Overhead

Control packets increase traffic.


Conclusion:

Connection Establishment and Connection Release are important processes in transport layer communication. Connection establishment creates a reliable communication path, and connection release safely closes it after data transfer. Together, they ensure organized and reliable communication.

CN_IMP_CH:2

 

1. Explain Guided Transmission Media (7 Marks)

Guided Transmission Media is a communication medium in which data signals travel through a physical path like wires or cables. It is called guided media because the signal is guided in a fixed direction through the cable. It is also known as Bounded Media or Wired Media.

Guided media is widely used in computer networks because it provides reliable and secure communication.

Types of Guided Transmission Media:

There are mainly three types of guided transmission media:

Guided Transmission Media
        |
  -----------------------
  |         |          |
Twisted   Coaxial   Optical
 Pair      Cable      Fiber

1) Twisted Pair Cable

Twisted pair cable consists of two insulated copper wires twisted together. The twisting helps to reduce electromagnetic interference and noise. It is the most commonly used transmission media in LAN and telephone systems.

Types of Twisted Pair Cable:

a) UTP (Unshielded Twisted Pair):

  • It has no extra shielding.

  • It is cheaper and easy to install.

  • Mostly used in LAN.

b) STP (Shielded Twisted Pair):

  • It has extra shielding for protection.

  • It reduces noise better than UTP.

  • It is more costly.

Features:

Sub-points:

  • Low cost and flexible.

  • Easy installation and maintenance.

  • Suitable for short-distance communication.

  • Limited bandwidth.

Advantages:

  • Cheap and simple.

  • Easily available.

  • Lightweight.

Disadvantages:

  • Affected by noise.

  • Low security.

  • Limited distance.

Example: Telephone lines, Ethernet cable


2) Coaxial Cable

Coaxial cable consists of a central copper conductor, insulation layer, metal shield, and outer plastic cover. It provides better protection from noise compared to twisted pair cable.

Structure:

  • Inner conductor

  • Insulating layer

  • Metallic shield

  • Outer cover

Features:

Sub-points:

  • Higher bandwidth than twisted pair.

  • Better noise resistance.

  • More durable.

  • Supports medium-distance communication.

Advantages:

  • Better signal quality.

  • More secure than twisted pair.

  • Less interference.

Disadvantages:

  • Costlier than twisted pair.

  • Difficult installation.

  • Less flexible.

Example: Cable TV, Broadband connection


3) Optical Fiber Cable

Optical fiber cable uses light signals to transmit data. It is made of thin glass or plastic fibers. It provides the fastest communication speed and highest bandwidth.

Types of Optical Fiber:

a) Single Mode Fiber:

  • Used for long-distance communication.

  • Uses single light path.

b) Multi Mode Fiber:

  • Used for short-distance communication.

  • Uses multiple light paths.

Features:

Sub-points:

  • Very high speed.

  • High bandwidth.

  • Long-distance communication.

  • Not affected by electromagnetic interference.

  • Highly secure.

Advantages:

  • Very fast data transfer.

  • High security.

  • Less signal loss.

  • Supports long-distance communication.

Disadvantages:

  • High installation cost.

  • Difficult to repair.

  • Fragile cable.

Example: Internet backbone, Fiber broadband


Comparison of Guided Media:

TypeSpeedCostNoiseDistance
Twisted PairLow to MediumLowHighShort
Coaxial CableMediumMediumLowMedium
Optical FiberVery HighHighVery LowLong

Conclusion:

Guided transmission media provides a fixed path for data communication. It is more reliable and secure than wireless communication. Twisted pair, coaxial cable, and optical fiber are the main types of guided media, each having different speed, cost, and uses.


Q.2 Explain Twisted Pair Cable with suitable diagram, advantages and disadvantages.

Definition

Twisted Pair Cable is a guided transmission medium consisting of two insulated copper wires twisted together. The twisting reduces electromagnetic interference and crosstalk between wires. It is widely used in telephone networks and LANs.


Diagram

Two copper wires are twisted together to form a twisted pair cable.


Types of Twisted Pair Cable

1. UTP (Unshielded Twisted Pair)

Definition

UTP is a twisted pair cable without any metallic shielding around the wires.


  • Does not have additional shielding.

  • Less expensive.

  • Commonly used in LAN networks.

2. STP (Shielded Twisted Pair)

Definition

STP is a twisted pair cable that contains a metallic shield around the twisted wires to reduce interference and noise.



  • Contains a protective metal shield.

  • Provides better protection against interference.

  • More expensive than UTP.


Working

  1. Data is transmitted as electrical signals through copper wires.

  2. The wires are twisted together to reduce noise and interference.

  3. One wire carries the signal while the other acts as a return path.

  4. The receiving device receives and interprets the signals.


Example

  • Telephone lines

  • Ethernet LAN cables (Cat5e, Cat6)

  • Office and home networks


Advantages

  1. Low cost and economical.

  2. Easy to install and maintain.

  3. Flexible and lightweight.

  4. Suitable for short-distance communication.

  5. Widely available and commonly used.


Disadvantages

  1. Limited transmission distance.

  2. Lower bandwidth compared to fiber optic cable.

  3. Susceptible to electromagnetic interference.

  4. Less secure than fiber optic cable.

  5. Signal attenuation increases over long distances.


Applications

  1. Telephone communication.

  2. Local Area Networks (LANs).

  3. Internet connections.

  4. Office networking.


3. Explain Coaxial Cable and Power Lines. (GTU Style – Long Answer)

Coaxial Cable

Definition:
Coaxial cable is a type of guided transmission media used to transmit data signals from one device to another. It consists of a central conductor covered by insulation, metallic shield, and outer plastic cover. It is widely used in television networks and internet connections.



Structure of Coaxial Cable:

Coaxial cable has four important parts:

1. Inner Conductor:
The inner conductor is made of copper and carries the actual data signal.

2.Insulator:
It is a non-conducting material placed around the inner conductor. It separates the conductor from the outer shield.

3. Metallic Shield:
It is made of metal mesh or foil. It protects the cable from electromagnetic interference and noise.

4. Outer Plastic Jacket:
It is the outermost layer which protects the cable from damage.

Characteristics of Coaxial Cable:

  • It has high bandwidth capacity.

  • It can carry data over long distances.

  • It provides better protection from noise.

  • It supports both analog and digital signals.

Advantages of Coaxial Cable:

1. High Speed:
It can transmit data faster than twisted pair cable.

2. Less Noise:
The metallic shield reduces interference.

3. Better Security:
Data transmission is more secure.

4. Long Distance Communication:
Signals can travel a longer distance without much loss.

5. Strong and Durable:
It is physically stronger than many other cables.

Disadvantages of Coaxial Cable:

1. Expensive:
It costs more than twisted pair cable.

2. Bulky:
It is thicker and less flexible.

3. Difficult Installation:
Installation and maintenance are not easy.

Applications of Coaxial Cable:

  • Cable television

  • Broadband internet

  • CCTV camera systems

  • Telephone lines

  • Radio communication


Power Lines

Definition:
Power lines are electrical wires used mainly to supply electricity. These lines can also be used for data communication using Power Line Communication (PLC) technology. In this method, both power and data signals travel on the same wire.

Working of Power Lines:

In power line communication, data is converted into electrical signals and sent through the existing power cables. At the receiving side, the signal is separated and converted back into data.

This method does not require separate communication cables.

Characteristics of Power Lines:

  • Uses existing electrical wiring.

  • Easy to install.

  • Low-cost communication medium.

  • Available in homes, offices, and industries.

Advantages of Power Lines:

1. Low Cost:
No extra cables are needed.

2. Easy Installation:
Uses already available wiring.

3. Wide Availability:
Electric lines are present almost everywhere.

4. Useful for Networking:
Can be used for internet and smart devices.

5. Saves Time:
Setup is faster than other transmission media.

Disadvantages of Power Lines:

1. High Noise:
Electrical devices create interference.

2. Low Speed:
Speed is less compared to fiber optic and coaxial cable.

3. Signal Disturbance:
Signal quality may change frequently.

4. Less Reliable:
Not suitable for high-speed communication.

Applications of Power Lines:

  • Home networking

  • Smart meters

  • Internet access

  • Smart grid systems

  • Industrial automation

Conclusion:

Coaxial cable is a reliable and high-speed 
transmission media with less interference, while power lines
are a low-cost solution that uses existing electrical wiring
for communication.
Both are useful in different communication systems.

4. Explain Fiber Optics with Diagram. (GTU Style – Long Answer)

Fiber Optics

Definition:
Fiber optics is a guided transmission media that uses -

light signals to transmit data from one place to another.

It is made of very thin strands of glass or plastic.

Data travels in the form of light pulses.

Diagram of Fiber Optics:

 

Parts of Fiber Optic Cable:

1. Core:
It is the innermost part of the cable made of glass or plastic.

Light travels through the core.

2. Cladding:
It surrounds the core and reflects light back into the core.

3. Outer Jacket:
It protects the cable from physical damage and moisture.

Working of Fiber Optics:

Fiber optics works on the principle of Total Internal

Reflection.

The light signal enters the core and keeps reflecting inside

the core until it reaches the destination.

In this way, data is transmitted at very high speed.

Characteristics of Fiber Optics:

  • Very high bandwidth.

  • Supports very long-distance communication.

  • Very low signal loss.

  • Not affected by electromagnetic interference.

  • Lightweight and thin.

Advantages of Fiber Optics:

1. High Speed:
It provides very fast data transmission.

2. Large Bandwidth:
It can carry a large amount of data.

3. Less Signal Loss:
Signal remains strong over long distances.

4. No Noise Interference:
It is not affected by electrical noise.

5. Secure Communication:
It is difficult to tap data.

Disadvantages of Fiber Optics:

1. Expensive:
Installation cost is high.

2. Difficult Installation:
Requires skilled persons.

3. Fragile:
Glass fibers can break easily.

4. Maintenance Costly:
Repairing is difficult and expensive.

Applications of Fiber Optics:

  • Internet and broadband connection

  • Telephone communication

  • Cable TV

  • Medical instruments

  • Military communication

  • Networking in companies

Conclusion:

Fiber optic cable is the fastest and most reliable 
transmission media. It provides high-speed communication
with less loss and no interference, so it is widely used
in modern communication systems. 

5. Explain Microwave Communication. (GTU Style – Easy Long Answer)

Microwave Communication

Definition:
Microwave communication is a type of wireless communication in which data is sent using microwave signals through air.

 It does not use any physical wire. The frequency of microwaves is between 1 GHz to 300 GHz.

It is mainly used for high-speed and long-distance communication.


Working of Microwave Communication

In microwave communication, the sender converts data into microwave signals and sends them through an antenna. These signals travel in a straight line and reach the receiver antenna.

This is called Line of Sight (LOS) communication, which means there should be no obstacle between sender and receiver.

If the distance is very long, repeater stations are used to make the signal stronger.

Diagram of Microwave Communication

  


Characteristics of Microwave Communication

  1. It is a wireless medium.
  2. It uses high-frequency signals.
  3. It supports fast communication.
  4. It requires line of sight.
  5. It is used for long-distance communication.

Types of Microwave Communication

1. Terrestrial Microwave

In terrestrial microwave communication, antennas are placed on towers on the earth. The signals travel from one tower to another.

For long distances, repeaters are used.

Uses:

  • Mobile towers
  • TV transmission
  • Internet networks

2. Satellite Microwave

In satellite microwave communication, signals are sent to a satellite and then the satellite sends them to another place on earth.

It is used for very long-distance communication.

Uses:

  • Satellite TV
  • GPS
  • Weather reports
  • International calls

Advantages of Microwave Communication

  1. High speed communication.
  2. No cable is required.
  3. Easy to install.
  4. Covers long distances.
  5. Supports large amount of data.

Disadvantages of Microwave Communication

  1. Needs clear path between antennas.
  2. Buildings and mountains can block signals.
  3. Weather can affect signals.
  4. Equipment cost is high.

Applications of Microwave Communication

  • Mobile communication
  • Satellite communication
  • Television broadcasting
  • Internet services
  • Radar systems

Conclusion

Microwave communication is a fast and useful wireless communication method. It is widely used for long-distance communication because it provides high speed and wide coverage.

Digital Modulation

Definition:

Digital modulation is a process of converting digital data into digital/analog signals for transmission over communication channels. In this process, one or more properties of the carrier signal such as amplitude, frequency, or phase are changed according to digital data.

It is used to send binary data (0 and 1) over long distances.

Need of Digital Modulation:

  • To transmit digital data efficiently.

  • To reduce noise effect.

  • To improve data transmission speed.

  • To make communication more reliable.

Types of Digital Modulation:

1. ASK (Amplitude Shift Keying)

In ASK, the amplitude of the carrier signal changes according to binary data, while frequency and phase remain constant.

  • Binary 1 → High amplitude

  • Binary 0 → Low amplitude

Example:
If data is 1010, amplitude changes high-low-high-low.

Advantages:

  • Simple and easy to implement.

Disadvantages:

  • More affected by noise.


2. FSK (Frequency Shift Keying)

In FSK, the frequency of the carrier signal changes according to binary data, while amplitude remains constant.

  • Binary 1 → High frequency

  • Binary 0 → Low frequency

Advantages:

  • Better noise resistance than ASK.

Disadvantages:

  • Requires more bandwidth.


3. PSK (Phase Shift Keying)

In PSK, the phase of the carrier signal changes according to binary data.

  • Binary 1 → One phase

  • Binary 0 → Opposite phase

Advantages:

  • High data transmission quality.

  • Better security.

Disadvantages:

  • Complex to implement.


Applications of Digital Modulation:

  • Mobile communication

  • Wi-Fi

  • Bluetooth

  • Satellite communication

  • Digital TV


Multiplexing

Definition:

Multiplexing is a technique in which multiple signals are combined into one signal and transmitted through a single communication channel.

It increases the efficiency of communication.

At the receiver side, the signals are separated by a process called Demultiplexing.

Working of Multiplexing:

  • Many input signals are combined by a multiplexer.

  • The combined signal is sent through one channel.

  • At the receiver, demultiplexer separates the signals.

Input Signals → Multiplexer → Communication Channel → Demultiplexer → Output Signals

Types of Multiplexing:

1. FDM (Frequency Division Multiplexing)

In FDM, the available bandwidth is divided into different frequency ranges, and each signal is transmitted on a separate frequency.

Example: Radio broadcasting.

Advantages:

  • Many signals transmitted at the same time.

Disadvantages:

  • Bandwidth wastage may occur.


2. TDM (Time Division Multiplexing)

In TDM, each signal gets a fixed time slot to use the channel.

Signals are transmitted one after another very quickly.

Example: Telephone systems.

Advantages:

  • Better use of bandwidth.

Disadvantages:

  • Synchronization is required.


3. WDM (Wavelength Division Multiplexing)

In WDM, different wavelengths of light are used to transmit multiple signals in fiber optic cables.

Example: Fiber optic communication.

Advantages:

  • Very high speed.

  • High capacity.

Disadvantages:

  • Costly technology.


Advantages of Multiplexing:

  1. Saves communication cost.

  2. Efficient use of bandwidth.

  3. Multiple signals use one channel.

  4. Improves communication speed.


Conclusion:

Digital modulation converts digital data into signals for transmission, while multiplexing combines multiple signals into one channel. Both are important techniques in modern communication systems for fast and efficient data transfer.

7. Explain Public Switched Telephone Network (PSTN). (GTU Style – Long Answer)

Public Switched Telephone Network (PSTN)

Definition:
Public Switched Telephone Network (PSTN) is the traditional telephone system used for voice communication. It is a worldwide network of telephone lines, switches, and exchanges that allows people to make telephone calls from one place to another.

It is also called the Plain Old Telephone System (POTS).

PSTN mainly works using circuit switching, where a dedicated communication path is established between sender and receiver during the call.


Components of PSTN

PSTN consists of the following main components:

1. Telephone Set:
It is the device used by users to make and receive calls.

2. Local Loop:
It is the connection between the user’s telephone and the nearest telephone exchange.

3. Switching Office (Exchange):
It connects calls between users by selecting the path.

4. Trunk Lines:
These are high-capacity lines connecting different switching offices.

5. Transmission Media:
It includes cables, optical fibers, and wireless links used for communication.


Working of PSTN

The working of PSTN is as follows:

1. Call Initiation:
When a user dials a number, the telephone sends signals to the local exchange.

2. Path Establishment:
The switching office creates a dedicated path to the receiver.

3. Communication:
Voice signals travel through the established path.

4. Call Termination:
When the call ends, the connection is disconnected.


Diagram of PSTN

 Telephone A → Local Exchange → Trunk Line → Local Exchange → Telephone B

Features of PSTN

  • Uses circuit switching.

  • Provides reliable voice communication.

  • Supports national and international calls.

  • Works through wired networks.

  • Widely used for many years.


Advantages of PSTN

1. Reliable Communication:
Provides stable voice quality.

2. Wide Coverage:
Available in many areas.

3. Simple Technology:
Easy to use and understand.

4. Secure Communication:
Dedicated path makes communication secure.


Disadvantages of PSTN

1. Expensive for Long Distance:
International calls cost more.

2. Limited for Data:
Not suitable for high-speed internet.

3. Requires Physical Wiring:
Installation and maintenance are costly.

4. Less Flexible:
Compared to modern VoIP systems.


Applications of PSTN

  • Home telephone service

  • Office communication

  • Emergency services

  • Fax communication

  • International calling


Conclusion

PSTN is the traditional and reliable telephone network used for voice communication. It uses circuit switching to establish a dedicated path between users. Although modern technologies like VoIP are growing, PSTN is still important in many communication systems.

OS_IMP

UNIT=1 Explain Process States (7 Marks – GTU Style) A process is a program that is currently running in the computer. During execution, a p...