100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Deadlock and its state $13.49   Add to cart

Class notes

Deadlock and its state

 2 views  0 purchase
  • Course
  • Institution

Easy notes that helps to undersatnd about the deadlock and its state

Preview 3 out of 27  pages

  • June 19, 2024
  • 27
  • 2023/2024
  • Class notes
  • Na
  • All classes
avatar-seller
CST 206 OPERATING SYSTEMS
MODULE 3

Process synchronization- Race conditions – Critical section problem – Peterson’s
solution, Synchronization hardware, Mutex Locks, Semaphores, Monitors –
Synchronization problems - Producer Consumer, Dining Philosophers and Readers-
Writers.
Deadlocks: Necessary conditions, Resource allocation graphs, Deadlock prevention,
Deadlock avoidance – Banker’s algorithms, Deadlock detection, Recovery from
deadlock.

PROCESS SYNCHRONIZATION
On the basis of synchronization, processes are categorized as one of the following two types:
• Independent Process
• Cooperative Process
Process synchronization problem arises in the case of Cooperative process because resources are shared
there.
Process synchronization is the task phenomenon of coordinating the execution of processes in such a way
that no two processes can have access to the same shared data and resources.
• It is a procedure that is involved in order to preserve the appropriate order of execution of
cooperative processes. In order to synchronize the processes, there are various synchronization
mechanisms.
• Process Synchronization is mainly needed in a multi-process system when multiple processes are
running together, and more than one processes try to gain access to the same shared resource or
any data at the same time.

RACE CONDITION
A race condition is a problem that occurs in an operating system where two or more processes or threads
are executing concurrently. The outcome of their execution depends on the order in which they are
executed. In a race condition, the exact timing of events is unpredictable, and the outcome of the execution
may vary based on the timing. This can result in unexpected or incorrect behaviour of the system.
For example,
If two threads are simultaneously accessing and changing the same shared resource, such as a variable or
a file, the final state of that resource depends on the order in which the threads execute. If the threads are
not correctly synchronized, they can overwrite each other's changes, causing incorrect results or even
system crashes.

Effects of Race Condition in OS:
In an operating system, a race condition can have several effects, which are :
1 . D e a d l o c k s : A race condition can cause deadlocks, where two or more processes are awaiting
the completion of a job by one another but are unable to move forward, can be brought on by a race
condition. This can happen if two processes try to access the same resource simultaneously, and the
operating system doesn't have a mechanism to ensure that only one can access the resource at a time.


1

, CST 206 OPERATING SYSTEMS
2 . D a t a c o r r u p t i o n : A race condition can cause data corruption, where two or more processes
simultaneously try to write/update the exact memory location. This can cause the data to be overwritten
or mixed up, resulting in incorrect results or program crashes.
3 . S e c u r i t y v u l n e r a b i l i t i e s : A race condition can also create security vulnerabilities in an
operating system. For example, an attacker may be able to exploit a race condition to gain unauthorized
access to a system or to escalate their privileges.
4 . P e r f o r m a n c e d e g r a d a t i o n : In some cases, a race condition can also cause performance
degradation in an operating system. This can happen if multiple processes are competing for the
same resources, such as CPU time or memory, and the operating system is unable to allocate these
resources efficiently.
PROGRAMS AND CRITICAL SECTIONS
• The part of the program (process) that is accessing and changing shared data is called its critical
section.




Critical Section
• The general way to do that is:




• Consider system of n processes {p0, p1, … pn-1}
• Each process has critical section segment of code
2

, CST 206 OPERATING SYSTEMS
• Process may be changing common variables, updating table, writing file, etc
• When one process in critical section, no other may be in its critical section
• Critical section problem is to design protocol to solve this.
• Each process must ask permission to enter critical section in entry section, may follow critical section
with exit section, then remainder section




Critical Section is the part of a program which tries to access shared resources. That resource may be any
resource in a computer like a memory location, data structure, CPU or any IO device .The critical section
cannot be executed by more than one process at the same time; operating system faces the difficulties in
allowing and disallowing the processes from entering the critical section.

The critical section problem is used to design a set of protocols which can ensure that the race condition
among the processes will never arise.

Solution to Critical Section Problem
There are 3 requirements that stand for a correct solution:

1. Mutual Exclusion: If one process is executing inside critical section then the other process must not
enter in the critical section.




3

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller chinnu2. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

73091 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.49
  • (0)
  Add to cart