CTEVT Regular/Back Exam-2081 Operating System solutions

 Define operating system. Explain the function of OS. [2+6]

Definition of Operating System :

An Operating System (OS) is system software that acts as an interface between the user and the hardware of a computer. It manages hardware resources and provides essential services for other software.

Functions of Operating System:

  1. Process Management:
    It manages the execution of processes, including scheduling, creation, and termination.

  2. Memory Management:
    It allocates and deallocates memory to programs and ensures efficient use of memory.

  3. File System Management:
    It organizes, stores, retrieves, and manages data on storage devices.

  4. Device Management:
    It controls hardware devices like printers, keyboards, and monitors through device drivers.

  5. Security and Access Control:
    It protects the system from unauthorized access and ensures data security.

  6. User Interface:
    It provides a user-friendly interface, like a command line or graphical user interface (GUI), to interact with the system.


What are the types of operating systems? Explain. [8]

Types of Operating Systems :

  1. Batch Operating System:
    Jobs are processed in batches without user interaction. Users submit tasks, and the system processes them one by one.
    Example: Early IBM systems.

  2. Time-Sharing Operating System:
    Multiple users share system resources simultaneously by giving each user a small time slice.
    Example: UNIX.

  3. Distributed Operating System:
    Manages a group of independent computers and makes them appear as a single system.
    Example: LOCUS, Windows Server.

  4. Real-Time Operating System (RTOS):
    Processes tasks within a defined time frame, critical for systems like medical devices or autopilot systems.
    Example: VxWorks.

  5. Network Operating System:
    Enables computers to communicate over a network and share resources like files and printers.
    Example: Windows Server, Linux.

  6. Mobile Operating System:
    Designed specifically for mobile devices to manage applications and hardware.
    Example: Android, iOS.


Define process control block (PCB). Differentiate between process and program. [2+4]

Definition of Process Control Block :

A Process Control Block (PCB) is a data structure used by the operating system to store information about a process. It contains all the details needed to manage and track a process during its execution.

Key Information Stored in a PCB:

  • Process ID: Unique identifier of the process.
  • Process State: The current state of the process (e.g., running, waiting).
  • Program Counter: Points to the next instruction to execute.
  • CPU Registers: Stores the process's CPU register values.
  • Memory Information: Details about memory allocated to the process.
  • I/O Status: Information on I/O devices assigned to the process.

Difference Between Process and Program :

AspectProcessProgram
Definition  A program in execution.A set of instructions written to perform a task.
StateDynamic (changes as it executes).Static (does not change while stored in memory).
LifetimeExists during execution and terminates afterward.Exists until deleted or modified by the user.
ExampleRunning a calculator application.The calculator application file stored on disk.

Define process scheduling. Consider the following set of processes having their burst time mentioned in milliseconds. Calculate the average waiting time using the round-robin algorithm with a quantum of 3 milliseconds.

ProcessArrival TimeBurst Time
P005
P113
P228
P336

Definition of Process Scheduling :

Process Scheduling is the mechanism used by the operating system to decide the order in which processes are executed. It ensures efficient CPU utilization and minimizes waiting time by allocating CPU time to processes based on specific algorithms.

Calculation of Average Waiting Time Using Round-Robin Algorithm :

Given:

  • Time Quantum: 3 milliseconds
  • Processes: P0, P1, P2, P3
  • Arrival Times and Burst Times:

Process

Arrival Time

Burst Time

P0

0

5

P1

1

3

P2

2

8

P3

3

6

 

Step-by-Step Solution:

1. Gantt Chart Construction:

Using the Round-Robin algorithm with a quantum of 3 milliseconds, the processes are scheduled as follows:

Time

Process Executed

0 - 3

P0

3 - 6

P1

6 - 9

P2

9 - 12

P3

12 - 14

P0

14 - 15

P1

15 - 18

P2

18 - 21

P3

21 - 22

P2

 

2. Completion Time (CT):

Process

Completion Time

P0

14

P1

15

P2

22

P3

21

 

3. Turnaround Time (TAT):

TAT = Completion Time - Arrival Time

Process

TAT

P0

14 - 0 = 14

P1

15 - 1 = 14

P2

22 - 2 = 20

P3

21 - 3 = 18

 

4. Waiting Time (WT):

WT = TAT - Burst Time

Process

WT

P0

14 - 5 = 9

P1

14 - 3 = 11

P2

20 - 8 = 12

P3

18 - 6 = 12

 

5. Average Waiting Time (AWT):

AWT = Total Waiting Time / Number of Processes
AWT = (9 + 11 + 12 + 12) / 4 = 44 / 4 = 11 milliseconds


What is memory management? Explain different types of memory allocation with an example. [2+8]

 Memory Management:

Memory management is a key function of the operating system that handles the allocation and deallocation of memory to processes and programs. It ensures efficient use of memory, prevents conflicts between processes, and keeps the system running smoothly.

Types of Memory Allocation:

  1. Contiguous Memory Allocation:

    • Memory is assigned in one continuous block.
    • Example: A program requiring 10 MB gets a single block of 10 MB.
    • Advantages: Simple and easy to manage.
    • Disadvantages: May cause external fragmentation, where free memory exists but isn’t usable because it’s scattered.
  2. Non-Contiguous Memory Allocation:

    • Memory is divided into smaller blocks, and programs can use blocks from different locations. Techniques like paging and segmentation are used to manage this.
    • Example: A program requiring 10 MB might get 5 MB in one place and 5 MB elsewhere, linked through a table.
    • Advantages: Solves external fragmentation.
    • Disadvantages: Adds complexity due to tables like page or segment tables.
Describe multiprogramming. Differentiate between internal and external fragmentation. [2+4]

Multiprogramming :

Multiprogramming is a technique used by operating systems to run multiple programs simultaneously.

  • The CPU switches between programs to keep itself busy while other programs wait for resources like input/output.
  • This improves CPU utilization and system efficiency.

Example: While a program waits for a file to load, the CPU executes another program instead of staying idle.

Difference Between Internal and External Fragmentation :

Internal Fragmentation

External Fragmentation

Occurs when memory is allocated in fixed-sized blocks and there is unused space inside a block.

Occurs when free memory is scattered across the system, making it difficult to allocate a large continuous block.

Example: Allocating 10 KB to a program needing 8 KB leaves 2 KB unused inside the block.

Example: Several free memory chunks exist, but none are large enough to fit a program needing 10 MB.

Happens due to fixed partitioning.

Happens due to dynamic partitioning.

Easier to solve with better memory allocation methods.

Solved using techniques like compaction or paging.


What is a file? Explain about file allocation methods. [2+8]

File:

A file is a collection of related data stored on a storage device, such as a hard drive. It is used to store information like documents, images, videos, or programs in a structured format so that it can be accessed and managed by the operating system.

File Allocation Methods:

File allocation methods determine how files are stored and organized on a storage device. The main methods are:

  1. Contiguous Allocation:

    • Files are stored in consecutive memory blocks.
    • Advantages: Easy to implement and provides fast access.
    • Disadvantages: Can lead to fragmentation and difficulty finding continuous free space.
    • Example: A 5 MB file is stored in 5 consecutive blocks.
  2. Linked Allocation:

    • Files are stored in scattered blocks, and each block contains a pointer to the next block.
    • Advantages: No fragmentation and easy to manage dynamic file sizes.
    • Disadvantages: Slower access due to pointer navigation.
    • Example: A file is stored in blocks 2 → 7 → 9, with each block pointing to the next.
  3. Indexed Allocation:

    • A separate index block contains pointers to all blocks of the file.
    • Advantages: Provides direct access to file blocks and supports dynamic allocation.
    • Disadvantages: Requires additional storage for the index block.
    • Example: An index block stores pointers to file blocks like 4, 8, 12.

Describe the terms:

i. Disk formatting        ii. Directory system        iii. Disk arm scheduling

i. Disk Formatting :

Disk formatting is the process of preparing a storage device, like a hard disk or USB drive, for data storage. It creates a file system that allows the operating system to read and write data.

  • Types of Formatting:
    • Low-level formatting: Divides the disk into physical sectors.
    • High-level formatting: Creates the file system (e.g., NTFS, FAT32).

ii. Directory System :

The directory system organizes files on a storage device. It uses a hierarchical structure of directories (folders) and subdirectories to manage and access files.

  • Types of Directory Systems:
    • Single-level: All files in one directory.
    • Two-level: Each user gets their directory.
    • Tree-structured: Directories have subdirectories.

iii. Disk Arm Scheduling :

Disk arm scheduling optimizes the movement of the disk's read/write head to access data efficiently. It reduces seek time (time taken to move the head to the desired track).

  • Common Algorithms:
    • FCFS (First-Come, First-Served): Serves requests in order of arrival.
    • SCAN: Moves the arm in one direction, then reverses.
    • C-SCAN: Only processes requests in one direction, then resets.
Define deadlock. Explain deadlock handling strategies.[3+6]

Definition of Deadlock :

A deadlock is a situation in a system where multiple processes are unable to proceed because each process is waiting for a resource that another process holds. As a result, none of the processes can complete their execution.

Example: Two processes, A and B, are stuck because:

  • Process A is waiting for a resource held by Process B.
  • Process B is waiting for a resource held by Process A.

Deadlock Handling Strategies:

There are several strategies to handle deadlocks:

  1. Deadlock Prevention:

    • Prevents deadlock by ensuring that at least one of the four necessary conditions (mutual exclusion, hold and wait, no preemption, circular wait) does not occur.
    • Example: Allocate all required resources to a process before it starts.
  2. Deadlock Avoidance:

    • Uses algorithms like the Banker’s Algorithm to decide whether a process can safely proceed without leading to deadlock.
    • Example: Check available resources before granting a request.
  3. Deadlock Detection and Recovery:

    • Allows deadlocks to occur but detects them using a resource allocation graph or similar techniques. The system then takes action to recover by terminating processes or preempting resources.
    • Example: Kill one or more processes involved in the deadlock to release resources.
  4. Ignore Deadlock (Ostrich Algorithm):

    • Assumes deadlocks are rare and does nothing to handle them.
    • Example: This is used in systems where deadlocks occur infrequently.
What is security attack? Explain active and passive attacks.[2+8].

Security Attack:

A security attack is any action that compromises the confidentiality, integrity, or availability of a system or data. It is an attempt to gain unauthorized access, disrupt operations, or steal sensitive information.

Example: Hackers stealing user credentials from a website.

Types of Security Attacks:

  1. Active Attacks:

    • Involve attempts to alter or manipulate data during transmission.
    • The attacker actively interferes with the system, causing damage or disruption.

    Examples of Active Attacks:

    • Modification of Messages: Changing data being transmitted (e.g., altering a bank transfer amount).
    • Masquerade: Pretending to be an authorized user to access restricted data.
    • Denial of Service (DoS): Overloading a system to make it unavailable.

    Impact: Active attacks are often detectable but cause significant harm to data integrity and system availability.

  2. Passive Attacks:

    • Involve monitoring or eavesdropping on data without modifying it.
    • The attacker aims to gather information silently without disrupting the system.

    Examples of Passive Attacks:

    • Eavesdropping: Intercepting communication to collect sensitive information (e.g., passwords).
    • Traffic Analysis: Observing patterns of communication to infer information about the sender and receiver.

    Impact: Passive attacks are harder to detect but compromise confidentiality.


Write short notes on:

                i. FIFO                ii. Paging

i. FIFO (First In, First Out):

FIFO is a simple scheduling and memory management technique used in operating systems. It processes tasks or manages memory in the order they arrive, like a queue.

    In Scheduling:

  • The first process to enter the queue is the first to be executed.
  • Example: In a print queue, the first document sent to the printer is printed first.
  • In Page Replacement:

    • When a new page is loaded into memory and no space is available, the oldest (first-loaded) page is removed.
    • Advantage: Simple to implement.
    • Disadvantage: It may replace frequently used pages, leading to inefficiency.

ii. Paging

Paging is a memory management technique that divides a program's memory into fixed-size blocks called pages, which are mapped to physical memory blocks called frames.

    How It Works:

  • The operating system maintains a page table to translate logical addresses (used by the program) into physical addresses (used by hardware).
  • Advantages:

    • Avoids external fragmentation.
    • Efficient use of memory.
  • Disadvantages:

    • May cause internal fragmentation.
    • Extra overhead for maintaining page tables.

No comments

Theme images by Jason Morrow. Powered by Blogger.