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

Os Notes 8

The document provides an overview of key concepts related to operating systems, including definitions of command interpreters, operating systems, processes, and more. It discusses various scheduling algorithms, process states, and synchronization problems such as deadlocks and the critical section problem. Additionally, it outlines services provided by operating systems and explains system calls, semaphores, and the reader-writer problem.

Uploaded by

sushanttandale6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views31 pages

Os Notes 8

The document provides an overview of key concepts related to operating systems, including definitions of command interpreters, operating systems, processes, and more. It discusses various scheduling algorithms, process states, and synchronization problems such as deadlocks and the critical section problem. Additionally, it outlines services provided by operating systems and explains system calls, semaphores, and the reader-writer problem.

Uploaded by

sushanttandale6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

a.

What is the purpose of command


interpreter?
Ans. The command interpreter (also called
the shell) allows users to interact with the
operating system by executing commands. It
processes user inputs, interprets them, and
passes them to the OS for execution.
b. Define the term Operating System.
Ans. An operating system (OS) is system
software that manages computer hardware
and software resources, providing a platform
for applications to run efficiently.
c. What is meant by multiprocessing
system?
Ans. A multiprocessing system is a computer
system with multiple processors working
simultaneously to execute multiple tasks,
improving performance and reliability.
d. What is Process?
Ans. A process is an instance of a program in
execution, consisting of program code, data,
and system resources such as memory and
CPU time.
e. Define System Program.
Ans. A system program is software that
provides an interface between hardware and
user applications, assisting in system
management, file handling, and device
control.
f. What is Context switch?
Ans. A context switch is the process of
saving the state of a currently running
process and loading the state of another
process to allow multitasking.
g. Which scheduler controls the degree
of multiprogramming? How?
Ans.The long-term scheduler controls the
degree of multiprogramming by determining
how many processes are allowed in the ready
queue at a time, balancing system
performance.
h. Define Burst Time.
Ans. Burst time is the total time a process
requires for execution on the CPU without
interruption.
i. What is Turn-Around Time?
Ans. Turn-around time is the total time taken
from process submission to its completion,
including waiting and execution time.
j. Define Dispatch Latency Time.
Ans. Dispatch latency is the time taken by
the CPU to switch from one process to
another, including the scheduling overhead
and context switching time.
k. What is Semaphores?
Ans. Semaphores are synchronization
primitives used in concurrent programming
to control access to shared resources and
avoid race conditions.
l. Define critical section problem and list
its solutions.
Ans. The critical section problem occurs in concurrent
programming when multiple processes access shared
resources simultaneously, leading to inconsistencies.
Solutions include:
1. Mutex Locks
2. Semaphores
3. Monitor Mechanism
4. Peterson’s Algorithm
m. Define Rollback.
Ans. Rollback is the process of reverting a
system to a previous safe state after
detecting an error or failure, commonly used
in databases and transaction systems.
n. What is meant by Deadlock?
And. Deadlock is a situation where two or
more processes wait indefinitely for
resources held by each other, preventing
further execution.
o. What is the role of MAX and NEED
array used in Banker's Algorithm?
Ans.  MAX Array: Defines the maximum
resources a process may need.
 NEED Array: Represents the remaining
resources a process requires to complete
execution.

p. Wait for graph is used for deadlock


avoidance in the system.
True/False. Justify.
Ans.
False. The wait-for graph is primarily used
for deadlock detection, not avoidance. It
helps identify circular waits in the system,
indicating potential deadlocks.
q. Define Swap Time.
Ans. Swap time is the time taken to transfer
a process from main memory to secondary
storage (or vice versa) during memory
management.
r. What is meant by Address Binding?
Ans. Address binding is the process of
mapping logical addresses to physical
addresses in memory management.
s. What is demand paging?
Ans. Demand paging is a memory
management technique where pages are
loaded into RAM only when they are
required, reducing memory wastage.
t.List various operations on files.
Ans.  Create a file
 Open a file
 Read from a file
 Write to a file
 Close a file
 Delete a file
u. List any four attributes on files.
Ans.
 Name (Identifier)
 Size (File length)
 Type (Format like .txt, .exe)
 Permissions (Read/Write/Execute access)
v. What do you mean by Seek Time in
Disk Scheduling?
Ans. Seek time is the time taken by the disk
arm to move to the track where the required
data is stored. It significantly impacts disk
performance.
w) Write any two services provided by OS.
Ans. 1. Program Execution – OS loads
programs into memory and runs them.
2. File Management – OS provides services
like file creation, deletion, reading, and
writing.
x) What is meant by System Call?
Ans. A system call is a request made by a
program to the operating system to perform
low-level operations (like file handling,
memory management, or process control)
that the program does not have direct access
to.
y) Define a safe state?
Ans. A system is in a safe state if there exists
a sequence of processes such that each
process can obtain its maximum required
resources without leading to a deadlock.
z) Define Dispatcher.
Ans. The dispatcher is a component of the OS
that gives control of the CPU to the process
selected by the short-term scheduler. It
performs context switching, switching to
user mode, and jumping to the process’s
starting point.

aa) What do you mean by Rollback?


Ans. Rollback is a technique used to handle
deadlocks or errors by reverting a process to
a previously saved safe state and restarting
it from there.
j) What do you mean by Deadlock?
Ans. A deadlock is a situation in which a set
of processes are blocked because each
process is holding a resource and waiting for
another resource held by some other
process, creating a cycle of dependency.

4 marks
a. List and explain services provided
by the operating system.
And. The OS provides several essential services to facilitate
efficient computer operation. These include:
1. Process Management – Handles
process creation, execution, scheduling,
and termination.
2. Memory Management – Allocates and
deallocates memory for programs.
3. File System Management – Manages
file storage, access, and permissions.
4. Device Management – Handles
communication between hardware and
software.
5. Security and Protection – Enforces
authentication, access control, and
encryption.
6. I/O System Management – Manages
input/output operations and device
drivers.
7. Error Detection and Handling –
Detects system errors and takes
corrective actions.
8. Networking – Provides network
protocols and communication services.
9. User Interface – Offers command-line
or graphical interfaces for users.

b. List two types of multiprocessor.


Explain both in detail.
Ans.  Symmetric Multiprocessing (SMP) –
All processors share memory and perform
tasks independently but communicate
efficiently.
 Asymmetric Multiprocessing (AMP) – One
processor is the master controlling the
system, while others act as slaves
performing assigned tasks.
c. List and explain system calls
related to Process and Job control.
Ans.  fork() – Creates a new process.
 exec() – Replaces a process’s memory with
a new program.
 wait() – Pauses execution until a child
process finishes.
 exit() – Terminates a process.
 kill() – Sends a signal to terminate a
process.
 getpid() – Retrieves the process ID.
 getppid() – Gets the parent process ID.
d. Explain various types of system
program.
Ans. System programs provide a user
interface for system services. The different
types are:
1. File Management Programs – Handle file
creation, deletion, and access (e.g., cp, mv,
rm).
2. Status Information Programs – Provide
system status and process details (e.g., top,
ps).
3. File Modification Programs – Include text
editors like vim, nano.
4. Programming Language Support – Includes
compilers, assemblers (e.g., gcc, python).
5. Communication Programs – Facilitate inter-
process or network communication (ping,
ssh).
6. Application Software – Software for
specific user needs like browsers, text
editors.
e. Explain process states in detail.
Ans. A process goes through several
states during its execution:
1. New – The process is created but not
yet ready to execute.
2. Ready – The process is waiting in the
queue for CPU allocation.
3. Running – The CPU is executing the
process instructions.
4. Waiting (Blocked) – The process is
waiting for an event (I/O completion,
resource availability).
5. Terminated – The process has
completed execution and is removed
from memory.
Process State Diagram:
New

Ready ←→ Running → Terminated

Waiting
f. Explain medium term scheduler.
Ans. The Medium-Term Scheduler
temporarily removes processes from
main memory (RAM) and moves them to
secondary storage (swap space).
It is used in swapping, where suspended
processes are moved out and brought
back when required.
This helps in efficient memory
management by reducing CPU load.
g. Explain Process Control Block
(PCB) in detail with the help of
diagram.
Ans. The Process Control Block (PCB) is a
data structure maintained by the OS for
each process. It stores important
process-related information, including:
1. Process ID (PID) – Unique identifier for
the process.
2. Process State – Whether it is Ready,
Running, Waiting, etc.
3. Program Counter (PC) – Address of the
next instruction to be executed.
4. CPU Registers – Stores intermediate
execution data.
5. Memory Management Information –
Base and limit registers, page tables.
6. I/O Status Information – List of I/O
devices allocated.
7. Accounting Information – Process
execution time, priority.
PCB Diagram:
----------------------------------
| Process ID (PID) |
| Process State |
| Program Counter |
| CPU Registers |
| Memory Management Information |
| I/O Status Information |
| Accounting Information |
----------------------------------
h. Describe process state with
suitable diagram
Ans. A process in an operating
system (OS) is an instance of a
running program. As a process
executes, it changes state based on
factors like CPU availability, I/O
operations, and scheduling decisions.
Process States
A process typically goes through the
following states:
1. New: The process is being created
but is not yet ready for execution.
2. Ready: The process is waiting for
CPU allocation to execute.
3. Running: The process is currently
being executed by the CPU.
4. Blocked (Waiting): The process is
waiting for an event (e.g., I/O
operation completion).
5. Terminated (Exit): The process has
finished execution and is removed
from memory.
Diagram of Process States
Below is a visual representation of
the process state transitions:
+---------+
| New |
+---------+
| Process Created
v
+------------+
| Ready |<------------+
+------------+ |
| CPU Assigned | Process
Preempted
v |
+------------+ +------------+
| Running |-------->| Blocked |
+------------+ +------------+
| Process Completed | I/O
Completed
v |
+------------+<------------------+
| Terminated |
+------------+

i. Write a short note on medium-term


scheduler.
Ans. A medium-term scheduler is
responsible for suspending and
resuming processes. It is mainly used in
swapping where a process is moved from
main memory to secondary storage to
reduce memory load and improve CPU
utilization.
Purpose: Reduces the number of active
processes in memory to optimize
performance.
Function: Suspends (swaps out)
processes and later resumes (swaps in)
when needed.
Example: If RAM is full, an idle process is
swapped to disk, and when required, it
is brought back to memory.
j. Explain multilevel feedback queue
algorithm.
Ans. MLFQ is an advanced CPU
scheduling algorithm that assigns
processes to multiple priority queues
and allows them to move between
queues based on behavior.
Multiple Queues: Each queue has a
different priority level.
Dynamic Priority: If a process uses too
much CPU, it moves to a lower-priority
queue. If it waits too long, it moves to a
higher-priority queue.
Starvation Prevention: Long-waiting
processes get priority boosts.
Example.
Queue 1 (Highest Priority): Time
Quantum = 5ms
Queue 2 (Medium Priority): Time
Quantum = 10ms

Queue 3 (Lowest Priority): FIFO (First-


Come, First-Served)
This algorithm is useful in interactive
systems where response time is crucial.
k. Consider the following set of
processes with the length of CPU
Burst Time and Arrival Time.
Processes CPU Burst Arrival Time
Time (in ms) (in ms)
P1 28 3
P2 7 1
P3 9 2

Calculate the Average Waiting Time and


Average Turn-around Time by using
Round Robin CPU Scheduling Algorithm.
(The time quantum is of 5 milliseconds)
Ans. Given Data:
Time Quantum = 5ms
We will compute Average Waiting Time
(AWT) and Average Turnaround Time
(ATAT) using the Round Robin
algorcrucia
l. What is CPU Scheduler? State the
criteria of CPU scheduling.
Ans. A CPU Scheduler selects which
process will run next from the ready
queue and assigns the CPU to it. It
operates when a process transitions
from ready to running or when
preemption occurs.
CPU Scheduling Criteria
1. CPU Utilization – Maximize CPU usage.
2. Throughput – Number of processes
completed per unit time.
3. Turnaround Time – Total time taken for
process execution.
4. Waiting Time – Time spent in the
ready queue.
5. Response Time – Time from
submission to first response.
m. What are the differences between
Preemptive and Non-preemptive
Scheduling?
Ans.
Non-
Preemptive
Feature preemptive
Scheduling
Scheduling
CPU can be CPU is not
CPU taken away taken until the
Allocatio from a process
n running completes or
process. blocks.
Generally May lead to
Respons better poor response
e Time response time for short
time. processes.
Higher due to
Lower, as there
Overhea frequent
is no forced
d context
switching.
switching.
Example Round Robin, First-Come-
Algorith Shortest First-Serve
ms Remaining (FCFS),
Time First Shortest Job
(SRTF). First (SJF).
Used in time-
Suitable for
Use Case sharing
batch systems.
systems.

n. List and explain four criteria for


computing various scheduling
algorithms.
Ans. 1. CPU Utilization – Keep CPU as
busy as possible.
2. Throughput – Number of processes
completed in a given time.
3. Turnaround Time – Total time from
arrival to completion.
4. Waiting Time – Time a process spends
in the ready queue.
o. Explain the readers and writes
problem which is a classical problem
of synchronization.
Ans. A synchronization problem where
multiple readers can read a shared
resource simultaneously, but writers
need exclusive access.
Readers can read concurrently.
Writers need exclusive access.
Solution: Use semaphores or locks to
prevent race conditions.
p. Describe solution for critical
section problem.
Ans. The critical section problem ensures
multiple processes do not access shared
resources simultaneously, leading to
race conditions.
Solutions:
1. Mutual Exclusion – Only one process in
the critical section at a time.
2. Progress – If no process is in the
critical section, others should proceed.
3. Bounded Waiting – Every process gets
a turn eventually.
Techniques include Peterson’s
Algorithm, Semaphores, and Monitors.
q. Describe in detail the ‘Dinning
Philosopher
Ans. The critical section problem ensures
multiple processes do not access shared
resources simultaneously, leading to
race conditions.
Solutions:
1. Mutual Exclusion – Only one process in
the critical section at a time.
2. Progress – If no process is in the
critical section, others should proceed.
3. Bounded Waiting – Every process gets
a turn eventually.
Techniques include Peterson’s
Algorithm, Semaphores, and Monitors.
r. Problem’ synchronization problem.
s. Explain Reader's writer's
problems.
Ans. Already covered in (g).
t.Explain semaphores and its types in
detail.
Ans. A semaphore is a variable used to
control access to shared resources.
Binary Semaphore (0 or 1, like a mutex)
Counting Semaphore (Allows multiple
processes access)
u. Explain WAIT and SIGNAL
semaphore operations.
Ans. WAIT(S): If S > 0, decrement and
enter; otherwise, wait.
SIGNAL(S): Increment S, allowing a
waiting process to proceed.
Example:
wait(S) { while (S <= 0); S--; }
signal(S) { S++; }
v. Explain different methods for
recovery from a deadlock.
Ans. Process Termination – Kill processes
to free resources.
2. Resource Preemption – Forcefully take
back resources.
3. Rollback – Revert processes to a
previous safe state.
w. Explain Resource Allocation graph
in detail.
Ans. A graph representation of resource
allocation, used to detect deadlocks.
Processes (P1, P2, etc.) are represented
as circles.
Resources (R1, R2, etc.) are squares.
Edges show resource requests and
assignments.
A circular wait condition in RAG indicates
a deadlock.
x. List and explain necessary
conditions for Deadlock occurrence.
Ans. A deadlock occurs when these four
conditions hold simultaneously:
1. Mutual Exclusion – Only one process
can use a resource at a time.
2. Hold and Wait – Processes hold some
resources while waiting for others.
3. No Preemption – Resources cannot be
forcibly taken.
4. Circular Wait – A closed chain of
processes waiting for each other’s
resources.
y. Consider the following page
reference string:
7, 5, 4, 9, 4, 7, 8, 5, 3, 4, 7, 9, 7, 4
Find the number of page fault for the
following algorithm with 3 frames:
(i) FIFO
(ii) MMF
Ans.
FIFO (First-In-First-Out) Algorithm
FIFO replaces the oldest page in
memory when a new page arrives and
the memory is full.
We will simulate the FIFO algorithm
and count the number of page faults.
(ii) MMF (Minimum Frequency
Method) Algorithm
MMF replaces the page that has been
used least frequently.
We will simulate this algorithm and
count the number of page faults.
z. Write the steps of calculate the
physical address by operating
system. Explain
with example.
Ans. The operating system translates
a logical address (generated by a
process) into a physical address
(actual location in memory).
Steps for Address Translation
1. CPU Generates a Logical Address
The logical address consists of page
number (P) and offset (D).
2. Look up in the Page Table
The OS maintains a page table that
maps logical pages to physical
frames.
Frame Number (F) = Page Table[P]
3. Compute the Physical Address
Physical Address = Frame Number ×
Frame Size + Offset
Example Calculation
Assume:
Logical Address = (Page 2, Offset
100)
Page Table: | Page No. | Frame No. |
|----------|----------| | 0 |5 ||1
|2 ||2 |7 |
Frame Size = 1024 bytes
Frame for Page 2 = 7
Physical Address = bytes
Thus, the logical address (2,100) is
mapped to physical address 7276.
This mechanism ensures memory
protection and process isolation in
paging-based memory management.
aa. What is a page fault? Explain the
different steps in handling a page
fault.
Ans. A page fault occurs when a program
tries to access a page that is not
currently present in the main memory.
The operating system must then retrieve
the page from secondary storage (disk).
Steps to handle a page fault:
1. Check if the memory reference is
valid: If the reference is invalid,
terminate the process.
2. Find a free frame: If there’s a free
frame, use it. Otherwise, select a frame
to replace using a page replacement
algorithm.
3. Issue a disk read operation: Load the
required page from the disk into the
selected frame.
4. Update the page table: Modify the
page table entry to reflect the new
frame location.
5. Restart the process: Resume the
instruction that caused the page fault.
bb. Explain Direct Access method with
advantages and disadvantages.
Ans. The Direct Access Method is used in
devices like hard drives, where data is
accessed directly by specifying the
location on the disk instead of
sequentially searching for it.
Advantages:
Faster than sequential access.
Suitable for applications requiring
frequent access to records.
Enables quick updates and
modifications.
Disadvantages:
More complex to manage than
sequential access.
Requires proper indexing or addressing
mechanisms.
May lead to fragmentation if not
managed properly.
cc. Explain contiguous memory
allocation method in detail.
Ans. In contiguous memory allocation, a
process is allocated a single continuous
block of memory.
Advantages:
Fast access due to fewer address
translations.
Simple implementation.
Disadvantages:
External fragmentation: Small gaps are
created between allocated blocks.
Fixed-size partitioning: Difficult to
allocate memory dynamically.
Compaction overhead: Periodic memory
reorganization may be needed.
dd. Write a short note on File
Directories.
Ans. A file directory stores information
about files, including file names,
locations, sizes, and permissions.
Types of directories:
1. Single-level directory: All files are
stored in a single directory.
2. Two-level directory: Each user has a
separate directory.
3. Hierarchical directory: A tree-like
structure with subdirectories.
4. Acyclic Graph Directory: Allows shared
files using links.
ee. Explain Indexed Allocation briefly.
Ans. In Indexed Allocation, a file has an
index block that stores pointers to data
blocks. This eliminates fragmentation
issues seen in contiguous allocation.
Advantages:
Efficient direct access to any file block.
Eliminates external fragmentation.
Disadvantages:
Overhead of storing index blocks.
Extra disk accesses for retrieving data.
ff. What is meant by free space
management? Define Bit vector and
Grouping.
And. Free Space Management keeps
track of free disk space to allocate it
efficiently.
Bit Vector: Uses a bitmap where each bit
represents a free (0) or allocated (1)
block.
Grouping: Stores addresses of multiple
free blocks in a single block, reducing
search time.
gg. Explain advantages and
disadvantages of Linked allocation
Method.
Ans. In linked allocation, each file is
stored as linked blocks, with each block
containing a pointer to the next.
Advantages:
No external fragmentation.
Efficient use of disk space.
Disadvantages:
Slower access as files must be read
sequentially.
Extra space required for pointers.
If a pointer is lost, part of the file
becomes inaccessible.
hh. Describe I/O Hardware with its
type of I/O devices.
Ans. I/O hardware enables
communication between the CPU and
external devices.
Types of I/O Devices:
1. Block Devices: Store and retrieve data
in fixed-size blocks (e.g., Hard disks,
SSDs).
2. Character Devices: Transfer data as a
stream (e.g., Keyboainaccessibl
3. Network Devices: Handle data
communication (e.g., Ethernet, Wi-Fi
cards).
ii. The request queue is a follows:
87, 148, 92, 171, 96, 131, 103, 71
Number of tracks = 0 to 199
Starting position or current head
position = 125. Find total head
movement by
applying SSTF (Shortest Seek Time
First) Disk Scheduling Algorithm.
Ans. Request queue: 87, 148, 92, 171,
96, 131, 103, 71
Initial Head Position: 125
Using Shortest Seek Time First
(SSTF):
Total Head Movement: 166
jj. Assume there are total 200 tracks
present on each surface of the disk, if
request
queue is 57, 60, 41, 20, 92, 162, 152,
40, 186. Initial position of head is at
99 track.
Apply FCFS disk scheduling Algorithm
and calculate total head movement?
Ans. Request queue: 57, 60, 41, 20,
92, 162, 152, 40, 186
Initial Head Position: 99
Total Head Movement: 495
kk. Write a note on interrupts.
Ans. An interrupt is a signal that informs
the CPU of an event requiring immediate
attention.
Types of Interrupts:
1. Hardware Interrupts: Generated by
external devices (e.g., keyboard,
mouse).
2. Software Interrupts: Triggered by
software (e.g., system calls).
3. Maskable Interrupts: Can be ignored
by the CPU if needed.
4. Non-maskable Interrupts: Cannot be
ignored and must be handled
immediately.
ll. Assume there are total 0-199
tracks that are present on each
surface of the disk. If
request queue is: 84, 145, 89, 168,
93, 128, 100, 68 and initial position of
the head is
125. Apply SCAN disk scheduling
algorithm and calculate total head
movemen
Ans. Request queue: 84, 145, 89, 168,
93, 128, 100, 68
Initial Head Position: 125
SCAN moves in one direction first,
then reverses.
Assuming movement towards 199
first:
1. 125 → 128 (3)
2. 128 → 145 (17)
3. 145 → 168 (23)
4. 168 → 199 (31) (end of disk)
5. 199 → 100 (99)
6. 100 → 93 (7)
7. 93 → 89 (4)
8. 89 → 84 (5)
9. 84 → 68 (16)
Total Head Movement: 205

You might also like