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

OS Important M-3

Uploaded by

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

OS Important M-3

Uploaded by

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

Operating Systems

rd
3 SEM Exam – Important Questions

MODULE – 3

1. What is critical section? What are the three requirements for critical section to satisfy
Ans:
Critical Section:

1. Exclusive Access: Critical section is a part of a program where shared resources are accessed or
modified.
2. Concurrency Concerns: It's crucial because multiple threads or processes may try to access shared
resources simultaneously.
3. Mutual Exclusion: Only one thread can execute the critical section at a time to prevent data
corruption or inconsistency.
4. Synchronization: Critical sections require synchronization mechanisms to ensure that only one
thread accesses the shared resource at any given time.

[Another Answer]
2. Illustrate Peterson’s solution for critical section problem
Ans:
3. What are monitors? Explain dining philosopher’s solution using monitor and using
semaphore.
Ans: Syntax and schematic view of Monitors:
[Extra Question]
Dining-Philosopher's problem using monitors:
4. What is Synchronization? Explain Synchronization Hardware
Ans:

Synchronization:

1. Coordination: Synchronization is about coordinating the execution of multiple threads or


processes to ensure orderly and controlled behavior.
2. Shared Resources: It involves managing access to shared resources, such as variables or data
structures, by multiple threads or processes to prevent conflicts and maintain data integrity.
3. Concurrency: Synchronization is crucial in concurrent programming to avoid race conditions,
where the outcome of operations depends on the timing of their execution.
4. Orderly Execution: By synchronizing threads or processes, synchronization ensures that operations
are performed in a predictable and consistent order, leading to correct and reliable program
behavior.

Synchronization Hardware:

1. Locks for Critical Sections:


 Critical sections, where shared resources are accessed, are protected using locks.
 Processes or threads acquire a lock before entering a critical section and release it when
exiting.
 This ensures that only one process can access the critical section at a time, preventing race
conditions.
2. Locking Mechanism Program:

3. Uniprocessor Environment:
 In a uniprocessor environment, preventing interrupts while accessing shared variables
ensures that instructions are executed in order without interruption.
 This prevents unexpected modifications to shared variables, as no other instructions are run
during critical sections.
4. Challenges in Multiprocessor Environment:
 Disabling interrupts on a multiprocessor system is less feasible due to the overhead
involved.
 Passing messages to all processors to disable interrupts delays entry into critical sections,
reducing system efficiency.
 Multiprocessor systems require more sophisticated synchronization mechanisms to
coordinate access to shared resources efficiently.
5. What is deadlock? What are necessary conditions for deadlock
Ans:

Deadlock:

Deadlock is a state in a computer system where two or more processes are unable to proceed
because each is waiting for the other to release a resource, resulting in a standstill situation where
no progress can be made. Deadlock typically occurs in concurrent systems where processes
compete for shared resources and can arise due to improper resource allocation and
synchronization.
5. Banker's Algorithm Problems: [ Prepare for this question – Very Important]
Ans:
6. Various methods to recovery from deadlock
Ans:
Various methods of recovery from deadlock include:

1. Deadlock Prevention:
 Proactive approach to prevent deadlock by ensuring that at least one of the necessary conditions
for deadlock cannot occur.
 Examples include resource allocation strategies, such as bankers' algorithm, which ensures that
processes' resource requests are granted only if the resulting state is safe and deadlock-free.
2. Deadlock Avoidance:
 Dynamic approach that involves carefully scheduling processes to avoid potential deadlock
situations.
 Techniques include resource allocation algorithms that use information about the current state
and future resource requests to decide whether to grant or deny resource requests.
 Examples include the use of resource allocation graphs and bankers' algorithm with additional
runtime checks.
3. Deadlock Detection and Recovery:
 Reactive approach that detects deadlock after it has occurred and takes corrective action to
recover from it.
 Techniques include periodically checking the system for deadlock using algorithms like the cycle
detection algorithm.
 Upon detecting deadlock, recovery methods involve breaking the deadlock by preempting
resources from some processes, killing some processes, or rolling back the system to a previously
known safe state.
4. Resource Preemption:
 Preempt resources from one or more processes to break the circular wait condition and resolve
the deadlock.
 Preemption involves forcibly removing resources from processes to allocate them to other
processes to satisfy their resource needs.
 Care must be taken to ensure that preemption does not lead to resource starvation or
inconsistency.
5. Process Termination:
 Terminate one or more processes involved in the deadlock to release their held resources.
 Selecting processes for termination can be based on factors such as process priority, resource
usage, and the impact of termination on system performance.
 Termination should be done carefully to minimize disruption to the system and ensure that
terminated processes do not leave inconsistent or corrupt data.
6. Rollback and Restart:
 Roll back the system to a previous checkpoint where deadlock did not exist and restart the
affected processes from that point.
 Rollback involves reverting the system's state to a consistent state prior to the occurrence of
deadlock.
 Restarting processes allows them to resume execution without being affected by the deadlock.
8. What is resource allocation Graph? Explain how it is very useful in describing deadly
embrace(deadlock) by considering an example

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy