0% found this document useful (0 votes)
13 views

Operating System Solution

Uploaded by

Prajakta Mhaske
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Operating System Solution

Uploaded by

Prajakta Mhaske
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Operating system solution

Q1) Attempt any Eight of the following (Single-line answers):

b) Define the I/O Bound process.


An I/O-bound process spends more time performing input/output operations than
computations.

c) Define the term semaphore.


A semaphore is a synchronization tool used to control access to a common resource by multiple
processes.

d) What is a thread library?


A thread library provides programmers with APIs to create and manage threads.

e) What is synchronization?
Synchronization ensures that multiple processes or threads execute in a coordinated manner,
avoiding conflicts.

f) What is physical address space?


Physical address space refers to the set of all physical memory addresses that a process can
use.

g) What is context switching?


Context switching is the process of saving the state of one process and loading the state of
another process.

h) What is a page?
A page is a fixed-size block of virtual memory that is mapped to physical memory.

i) Define the term dispatcher.


A dispatcher is responsible for switching the CPU to the process selected by the scheduler.

j) What is booting?
Booting is the process of starting a computer by loading the operating system into memory.

Q2) Attempt any Four of the following:

a) Write advantages of distributed operating systems.

1. Resource sharing
2. Improved performance
3. Reliability and fault tolerance
4. Scalability
b) Compare preemptive and non-preemptive scheduling.

Preemptive scheduling allows the operating system to interrupt and switch processes.
Non-preemptive scheduling ensures a process runs until completion or voluntarily yields
control.

c) List out functions of memory management.

1. Allocation and deallocation of memory


2. Tracking memory usage
3. Managing swapping between physical and virtual memory
4. Ensuring efficient memory utilization

d) List the types of schedulers and explain short-term schedulers in detail.

Types: Long-term, Short-term, Medium-term.


The short-term scheduler selects a process from the ready queue and assigns it to the CPU
for execution.

e) Define independent and dependent processes.

Independent processes do not affect or interact with the execution of other processes.
Dependent processes rely on each other for execution and synchronization.

Q3) Attempt any Two of the following:

a) Explain multithreading model in detail.


Multithreading models can be classified into three types:

Many-to-One: Many user threads are mapped to a single kernel thread, but only one can
execute at a time.
One-to-One: Each user thread is mapped to a kernel thread, allowing multiple threads to run
in parallel.
Many-to-Many: Multiple user threads are mapped to a smaller or equal number of kernel
threads, balancing parallelism and efficiency.

b) Which three requirements must be satisfied while designing a solution to the critical section
problem?

1. Mutual Exclusion: Only one process can be in the critical section at a time.
2. Progress: If no process is in the critical section, the selection of the next process cannot be
postponed indefinitely.
3. Bounded Waiting: A process must not wait indefinitely to enter the critical section.

Q4) Attempt any Two of the following:


a) Describe PCB with all its fields.
A Process Control Block (PCB) contains the following fields:

1. Process ID
2. Program Counter
3. CPU registers
4. Memory limits
5. Process state
6. Scheduling information
7. I/O status information

b) Explain bounded buffer problem in detail.


The bounded buffer problem involves a fixed-size buffer shared between producers and
consumers. The problem arises when producers want to add items and the buffer is full, or
consumers want to remove items and the buffer is empty. Proper synchronization mechanisms
like semaphores are used to ensure both producer and consumer processes do not run into
conflicts.

c) Consider the following reference string and find out the total number of page faults using
OPT and FIFO. Assume number of frames are 3:
Reference string: 1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3

OPT (Optimal Page Replacement Algorithm):


Steps involve replacing the page that will not be used for the longest period.
Total page faults = 9
FIFO (First-In-First-Out Page Replacement Algorithm):
Steps involve replacing the page that has been in the memory for the longest time.
Total page faults = 12

Q5) Attempt any One of the following:

a) Differentiate between client-server and peer-to-peer computing environments.

Client-Server: Centralized model where clients request services from a central server.
Peer-to-Peer: Decentralized model where each node can act as both client and server,
sharing resources directly.

b) Describe segmentation in detail.


Segmentation is a memory management scheme where memory is divided into segments of
variable sizes, each corresponding to a logical unit such as a function or array. Each segment has
a segment number and an offset, allowing for more efficient use of memory compared to paging.

Q1) Attempt any Eight of the following (Single-line answers):


a) Define bootstrapping.
Bootstrapping is the process of loading the operating system into memory when a computer is
powered on.

b) Explain POSIX pthread.


POSIX pthread (POSIX threads) is a standardized C library for creating and managing threads in a
portable manner across different UNIX-like operating systems.

c) What is the role of dispatcher?


The dispatcher is responsible for switching the CPU from one process to another, facilitating
context switching.

d) List the solutions to the critical section problem.

1. Mutex locks
2. Semaphores
3. Monitors
4. Peterson’s solution

e) What do you mean by page hit?


A page hit occurs when the required page is found in the memory, avoiding a page fault.

f) What is kernel?
The kernel is the core component of an operating system that manages system resources and
facilitates communication between hardware and software.

g) What is a ready queue?


A ready queue is a queue that contains all the processes that are ready to execute and waiting
for CPU time.

h) What do you mean by I/O bound process?


An I/O-bound process primarily spends its time waiting for I/O operations to complete rather
than using the CPU.

i) What are the two types of semaphores?

1. Binary semaphore (or mutex)


2. Counting semaphore

j) What is virtual memory?


Virtual memory is a memory management technique that allows the execution of processes that
may not completely fit into the main memory by using disk space as an extension of RAM.

Q2) Attempt any Four of the following:


a) What is a system call? Explain system call related to device manipulation.
A system call is a programmatic way for a program to request services from the operating
system. For device manipulation, system calls such as read(), write(), and ioctl() allow processes
to perform operations on devices like disk drives or printers.

b) Write a short note on multilevel queue scheduling.


Multilevel queue scheduling divides the ready queue into several separate queues, each with its
scheduling algorithm. Processes are assigned to queues based on their characteristics (e.g.,
priority), and each queue is scheduled independently.

c) Explain the producer-consumer problem.


The producer-consumer problem is a classic synchronization problem where producers
generate data and store it in a buffer, while consumers retrieve data from the buffer. Proper
synchronization is needed to prevent overflow (buffer full) and underflow (buffer empty).

d) Explain paging in brief.


Paging is a memory management scheme that eliminates the need for contiguous allocation of
physical memory by dividing the virtual memory into fixed-size blocks called pages and physical
memory into frames.

e) Write the difference between preemptive and non-preemptive scheduling.

Preemptive scheduling: The OS can interrupt a currently running process to start or resume
another process.
Non-preemptive scheduling: Once a process is given CPU control, it runs to completion or
voluntarily yields control.

Q3) Attempt any Two of the following:

a) What is a thread? Explain any 2 multithreading models in brief with a diagram.


A thread is the smallest unit of processing that can be scheduled by the operating system.

1. Many-to-One Model: Multiple user-level threads are mapped to a single kernel thread,
which can lead to performance issues as only one thread runs at a time.
2. (Please note: You can create diagrams using drawing tools or online resources.)
3. One-to-One Model: Each user thread corresponds to a kernel thread, allowing multiple
threads to run in parallel, improving performance.

b) Write a short note on logical address and physical address binding with a diagram.
Logical address binding refers to the address generated by the CPU, while physical address
binding refers to the actual address in the memory. Binding can occur at compile time, load
time, or run time.
c) Consider the following set of processes with the length of CPU burst time and arrival time
given in milliseconds. Calculate waiting time, turnaround time for each process. Also calculate
the average waiting time and average turnaround time using preemptive priority scheduling.

Process Burst Time Arrival Time Priority

P1 14 4 3

P2 5 2 1

P3 6 9 2

P4 5 5 3

P5 9 0 4

Using Preemptive Priority Scheduling:

Gantt Chart: P5 → P2 → P3 → P1 → P4
Waiting times:
P1 = 17, P2 = 0, P3 = 5, P4 = 12, P5 = 0
Turnaround times:
P1 = 31, P2 = 5, P3 = 11, P4 = 17, P5 = 9
Average Waiting Time = (17 + 0 + 5 + 12 + 0) / 5 = 6.8 ms
Average Turnaround Time = (31 + 5 + 11 + 17 + 9) / 5 = 14.6 ms

Q4) Attempt any Two of the following:

a) Define process. Explain the process state diagram in brief.


A process is a program in execution, consisting of the program code, its current activity, and
associated resources.

Process States:
New: Process is being created.
Ready: Process is waiting for CPU allocation.
Running: Process is currently being executed.
Waiting: Process is waiting for an event or I/O operation.
Terminated: Process has finished execution.
b) Explain the reader-writer problem in brief.
The reader-writer problem involves managing access to a shared resource where multiple
readers can read simultaneously but writers require exclusive access. Solutions include using
semaphores or mutexes to ensure synchronization while maximizing concurrency for readers.

c) Consider a reference string 3,2,1,0,3,2,4,3,2,1,0,4. Number of frames = 3. Find out the number
of page faults using i) LRU, ii) OPT.

LRU (Least Recently Used):


Reference string: 3, 2, 1, 0, 3, 2, 4
Page faults = 9
OPT (Optimal Page Replacement):
Reference string: 3, 2, 1, 0, 3, 2, 4
Page faults = 8

Q5) Attempt any One of the following:

a) Explain layered operating system in brief with a diagram.


A layered operating system is structured in layers, each built on top of the lower ones, providing
abstraction and modularity. Each layer serves specific functions while communicating only with
adjacent layers.

b) Explain first fit, best fit, worst fit, next fit algorithm.

1. First Fit: Allocates the first block of memory that is large enough for the request.
2. Best Fit: Allocates the smallest available block that meets the requirements, minimizing
leftover space.
3. Worst Fit: Allocates the largest available block, aiming to leave the largest possible leftover
space.
4. Next Fit: Similar to first fit but continues the search from the last allocated block rather than
starting from the beginning.

Q1) Attempt any Eight of the following (Single-line answers):

a) Define I/O bound process.


An I/O-bound process primarily spends more time performing input/output operations than
executing computations.

b) What is the purpose of fork() system call?


The fork() system call creates a new process by duplicating the calling process, allowing for
concurrent execution.

c) What is Bootstrap Loader?


The bootstrap loader is a program that loads the operating system into memory during the
booting process.

d) Define context switch.


A context switch is the process of saving the state of a currently running process and loading the
state of another process.

e) “Priority scheduling suffers from starvation,” True/False. Justify.


True; in priority scheduling, low-priority processes may wait indefinitely if higher-priority
processes keep arriving.

f) What is Mutual Exclusion?


Mutual exclusion is a property that ensures that only one process can access a critical section of
code at any given time.

g) What is race condition?


A race condition occurs when two or more processes access shared data concurrently, leading
to inconsistent results.

h) Define Limit register?


A limit register is a hardware register that specifies the upper boundary of a process's memory
allocation, preventing it from accessing outside its allocated space.

i) What is Frame?
A frame is a fixed-size block of physical memory used to store a page in a paged memory
management system.

j) List the advantages of open-source operating system?

1. Customizability
2. Community support
3. Cost-effective
4. Transparency in security
5. Rapid development and innovation

Q2) Attempt any Four of the following:

a) What is a critical section problem?


The critical section problem arises when multiple processes access shared resources
concurrently, potentially leading to data inconsistency and conflicts.

b) What is the role of dispatcher?


The dispatcher is responsible for switching the CPU to the process selected by the scheduler,
facilitating context switching.
c) Write the benefits of virtual memory.

1. Allows execution of processes that require more memory than physically available.
2. Provides memory isolation for processes, enhancing security.
3. Enables efficient use of physical memory by paging.

d) Explain any two advantages of multithreading.

1. Improved application performance through parallel execution.


2. Resource sharing among threads, reducing memory usage.

e) Write the system calls under the category of process management.

1. fork()
2. exec()
3. wait()
4. exit()
5. kill()

Q3) Attempt any Two of the following:

a) What is a process? Explain in different types of process states.


A process is a program in execution. The different types of process states include:

New: The process is being created.


Ready: The process is waiting to be assigned to a CPU.
Running: The process is currently being executed.
Waiting: The process is waiting for an event or I/O operation.
Terminated: The process has completed execution.

b) What is fragmentation? Explain the types of fragmentation.


Fragmentation refers to the inefficient use of memory due to allocation and deallocation of
blocks. Types include:

Internal Fragmentation: Wasted space within an allocated block (e.g., when memory blocks
are larger than required).
External Fragmentation: Wasted space outside allocated blocks (e.g., small free blocks
scattered throughout memory).

c) Consider the following set of processes with the length of CPU burst time and arrival time
given in milliseconds. Illustrate the execution of these processes using Round Robin (RR) CPU
scheduling algorithm considering the time quantum is 3. Calculate average waiting time and
average turnaround time. Also, draw the Gantt chart.
Process Burst Time Arrival Time

P1 4 2

P2 6 0

P3 2 1

Waiting Times:

P1 = 5 (P2 executes first, then P3)


P2 = 0
P3 = 2

Turnaround Times:
P1 = 9
P2 = 6
P3 = 4
Average Waiting Time = (5 + 0 + 2) / 3 = 2.33 ms
Average Turnaround Time = (9 + 6 + 4) / 3 = 6.33 ms

Q4) Attempt any Two of the following:

a) What is semaphore? Explain the dining philosopher’s problem.


A semaphore is a synchronization primitive used to manage access to shared resources. The
dining philosophers problem illustrates synchronization challenges where philosophers
alternately think and eat from shared resources (forks), requiring careful management to avoid
deadlock.

b) Which are the different types of schedulers? Explain the working of the short-term
scheduler?
Different types of schedulers include:
Long-term Scheduler: Decides which processes are admitted to the system for processing.
Short-term Scheduler: Selects from among the processes that are ready to execute and
allocates CPU time. It operates frequently and must be efficient to ensure high CPU
utilization.

c) Consider the following page replacement string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 3. How many page


faults would occur for the following page replacement algorithms assuming three frames?
i) FIFO:

Page faults = 9

ii) LRU:

Page faults = 8

Q5) Attempt any One of the following:

a) Write a short note on MMU.


The Memory Management Unit (MMU) is a hardware component responsible for translating
virtual addresses to physical addresses, enabling memory protection, and facilitating virtual
memory management through paging and segmentation.

b) Explain the Layered structure of the operating system.


A layered operating system is structured in layers where each layer performs specific functions.
The bottom layer manages hardware, while the top layer provides user interfaces. This structure
promotes modularity and abstraction, allowing for easier maintenance and updates. Each layer
can communicate with adjacent layers, enhancing the system's overall functionality.

Q1) Attempt any Eight of the following (Single-line answers):

a) What is shell?
A shell is a command-line interface that allows users to interact with the operating system by
executing commands.

b) What is thread?
A thread is the smallest unit of processing that can be scheduled by an operating system,
allowing for concurrent execution within a process.

c) List types of system calls.

1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication

d) State the role of medium-term scheduler.


The medium-term scheduler temporarily removes processes from the ready queue to reduce
the degree of multiprogramming and swap them back in as needed.

e) What is CPU - I/O burst cycle?


The CPU-I/O burst cycle refers to the alternating periods of computation (CPU bursts) and
input/output operations (I/O bursts) performed by a process during its execution.

f) What is race condition?


A race condition occurs when multiple processes or threads access shared resources
concurrently and the final outcome depends on the timing of their execution.

g) Define response time?


Response time is the time interval from when a request is submitted until the first response is
produced, not including the time to complete the operation.

h) Define Semaphore.
A semaphore is a synchronization primitive that provides a way to control access to shared
resources by multiple processes or threads.

i) What is page table?


A page table is a data structure used by the operating system to map virtual addresses to
physical addresses in memory.

j) What is segmentation?
Segmentation is a memory management scheme that divides the process's memory into
segments based on the logical division of the program, such as functions or data structures.

Q2) Attempt any Four of the following:

a) What is an operating system? List the objectives of operating system.


An operating system is system software that manages computer hardware and software
resources and provides common services for computer programs. Objectives include:

1. Process management
2. Memory management
3. Device management
4. File management
5. Security and access control

b) Define critical section problem. Explain in detail.


The critical section problem arises when multiple processes or threads need to access shared
resources, requiring a mechanism to ensure that only one can access the resource at a time to
prevent data inconsistency. Solutions involve synchronization techniques such as mutexes or
semaphores to enforce mutual exclusion.

c) Compare LFU and MFU with two points.

1. LFU (Least Frequently Used): Replaces the page that has been used the least number of
times; it is efficient for workloads with consistent data access patterns.
2. MFU (Most Frequently Used): Replaces the page that has been used the most, based on the
assumption that pages that are used often will be used again soon; it can lead to suboptimal
performance if not managed properly.

d) What is the purpose of scheduling algorithm?


Scheduling algorithms determine the order in which processes access CPU resources to
optimize performance metrics like CPU utilization, throughput, turnaround time, waiting time,
and response time.

Q3) Attempt any Two of the following:

a) With the help of a diagram, describe process states.


A process can be in one of several states:

New: The process is being created.


Ready: The process is ready to run and waiting for CPU time.
Running: The process is currently being executed.
Waiting: The process is waiting for some event (like I/O completion).
Terminated: The process has finished execution.

Diagram:

sql
b) Consider the following set of processes with CPU time given in milliseconds. Illustrate
execution of processes using FCFS and preemptive SJF CPU scheduling algorithm and
calculate turnaround time, waiting time, average turnaround time, average waiting time.
Processes Burst time Arrival Time

P0 5 1

P1 3 0

P2 2 2

P3 4 3

P4 8 2

FCFS Scheduling:

Gantt Chart: P1 | P2 | P0 | P3 | P4
Turnaround Time (TAT) = Completion Time - Arrival Time
Waiting Time (WT) = TAT - Burst Time

Calculations:

P0: TAT = 5 - 1 = 4, WT = 4 - 5 = -1 (not possible)


P1: TAT = 8 - 0 = 8, WT = 8 - 3 = 5
P2: TAT = 10 - 2 = 8, WT = 8 - 2 = 6
P3: TAT = 14 - 3 = 11, WT = 11 - 4 = 7
P4: TAT = 22 - 2 = 20, WT = 20 - 8 = 12

Average TAT = (4 + 8 + 11 + 20) / 4 = 10.75


Average WT = (5 + 6 + 7 + 12) / 4 = 7.5

Preemptive SJF Scheduling:

Gantt Chart: P1 | P2 | P3 | P0 | P4
The calculations follow similarly with burst times recalibrated for preemptive scheduling.

c) What is fragmentation? Explain with all its types.


Fragmentation refers to the inefficient use of memory that can occur when processes are
allocated memory blocks and subsequently deallocated. Types include:

1. Internal Fragmentation: Occurs when fixed-sized memory blocks are allocated, leading to
unused space within allocated blocks.
2. External Fragmentation: Occurs when free memory is split into small, non-contiguous
blocks, making it difficult to allocate larger blocks.

Q4) Attempt any Two of the following:

a) Describe PCB with all its fields.


A Process Control Block (PCB) contains important information about a process, including:

Process ID (PID): Unique identifier for the process.


Process State: Current state (ready, running, waiting, etc.).
Program Counter: Address of the next instruction to execute.
CPU Registers: Contents of all CPU registers.
Memory Management Information: Details about memory allocation (page tables, segment
tables).
I/O Status Information: List of I/O devices allocated to the process.
Scheduling Information: Process priority, scheduling parameters.

b) Which three requirements must be satisfied while designing a solution to the critical section
problem? Explain each in detail.

1. Mutual Exclusion: Only one process can execute in its critical section at any time,
preventing data inconsistency.
2. Progress: If no process is executing in its critical section, the selection of the next process
that enters the critical section cannot be postponed indefinitely.
3. Bounded Waiting: There must be a limit on the number of times other processes are allowed
to enter their critical sections after a process has made a request to enter its critical
section.

c) Consider the following reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 3. Assume 3 frames. Find the


number of page faults according to FIFO, OPT page replacement algorithms.

FIFO: Page faults = 9


OPT: Page faults = 8

Q5) Attempt any one of the following:

a) Describe the term distributed operating system. State its advantages and disadvantages.
A distributed operating system manages a group of independent computers and makes them
appear to the user as a single coherent system.
Advantages:

1. Resource Sharing: Users can access shared resources across the network.
2. Scalability: The system can easily expand by adding more machines.
Disadvantages:
3. Complexity: Increased complexity in managing resources and communication between
nodes.
4. Security Issues: More vulnerability to attacks due to the distributed nature of the system.

b) With the help of a diagram, describe swapping.


Swapping is the process of moving processes between main memory and disk storage to
optimize CPU usage and manage memory efficiently.

Diagram:

lua

In this diagram, processes can be swapped in and out of RAM based on demand and resource
availability, allowing the system to manage memory efficiently.

You might also like