RACE CONDITION AND CRITICAL
SECTION
Presented by the students of B. P. Poddar Institute of
Management and Technology
Team
SREETAMA GHOSH (11500223095)
SRINJITA DAS(11500223096)
SUJAL VATS(11500223097)
SUJATO HUI(11500223098)
CONTENTS
• RACE CONDITON
• CRITICAL SECTION
• SOLUTION CRITERIA
• SOLUTION
• REQUIREMENTS
• CONCLUSION
• REFERENCES
RACE CONDITON
• When 2 or more processes are reading or writing some shared
data and the final result depends on who runs precisely when, is
called race condition.
• Race condition occurs when two or more operations occur in an
undefined manner.
• Race condition should be avoided because they can cause fine
errors in application and are difficult to debug.
CRITICAL SECTION
• A critical section is a block of code that only one process
at a time can execute.
• The critical section problem is to ensure that only one
process at a time is allowed to be operating in its critical
section.
• Each process takes permission from operating system to
enter into the critical section:
1. Entry section
2. Remainder section
3. Exit section
SOLUTION CRITERIA
• Solution of critical section must satisfy:
1. Mutual exclusion: if a process is executing in its critical
section, then no other process is allowed to execute in
the critical section
2. Progress: if no process is in the critical section, then no
other process from outside can block it from entering the
critical section.
3. Bounded waiting: a bound must exit 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 and before that request is granted.
SOLUTION
• OS handles critical section problem by using
kernel, classified as:
1. Preemptive kernel: the operating system can
interrupt a running process and switch to
another, even if the first process hasn't
finished or yielded control
2. Non preemptive kernel: In contrast, a non-
preemptive kernel requires a running process
to voluntarily release the CPU before another
process can execute.
REQUIREMENTS
• At any time only one process is allowed to enter in its critical section.
• Solution is implemented purely in software.
• Process cannot prevent others process from entering into critical section.
CONCLUSION
• A race condition in an operating system occurs when two or more processes or threads
concurrently access and manipulate shared data, and the final outcome depends on the
specific order in which these operations are interleaved.
• A critical section is a code segment within a process where shared resources or data are
accessed and modified.
• The critical section problem arises when multiple processes need to enter their respective
critical sections to access shared resources, and the operating system must ensure that only
one process can execute within its critical section at any given time to prevent race
conditions.
REFERENCES
• Operating System Concepts by Abraham Silberschatz and James Peterson
• Andrew Tanenbaum's “Modern Operating Systems.”
• Silberschatz's Operating System Concepts
THANK YOU