SlideShare a Scribd company logo
Bakery Algorithm
Name: S. M. Dedar Alam
ID: 171 016 042
Primeasia University
 Introduction
 Background
 Working Principle
 Real Life Example
 Analysis
 Conclusion
Introduction
This algorithm solves the critical section problem for n processes in software. The basic idea is
that of a bakery customers take numbers, and whoever has the lowest number gets service
next. Here, of course, "service" means entry to the critical section.
Background
In computer science, it is common for multiple threads to simultaneously access the same
resources. Data corruption can occur if two or more threads try to write into the same
memory location. Lamport's bakery algorithm is one of many mutual exclusion algorithms
designed to prevent concurrent threads entering critical sections of code concurrently to
eliminate the risk of data corruption.
Working Principle
 Before entering its critical section, the process receives a number. Holder of the smallest
number enters the critical section.
 If processes Pi and Pj receive the same number
if i < j
Pi is served first;
else
Pj is served first.
 The numbering scheme always generates numbers in increasing order of enumeration; i.e.,
1, 2, 3, 3, 3, 3, 4, 5................
Wait to Turn
When 245 Displayed go to Counter
Real Life Example
Simplified Analysis of Bakery Algorithm
Example
P0 P1 P2 P3 P4
Example
P0 P1 P2 P3 P4
0 0 0 0 0
Example
P0 P1 P2 P3 P4
0 0 1 0 0
Example
P0 P1 P2 P3 P4
0 0 1 2 0
Example
P0 P1 P2 P3 P4
0 0 1 2 3
Example
P0 P1 P2 P3 P4
0 4 1 2 3
Example
P0 P1 P2 P3 P4
0 4 1 2 3
Example
P0 P1 P2 P3 P4
0 4 0 2 3
Example
P0 P1 P2 P3 P4
0 4 0 0 3
Example
P0 P1 P2 P3 P4
0 4 0 0 0
Example
P0 P1 P2 P3 P4
0 0 0 0 0
Example
P0 P1 P2 P3 P4
0 0 2 2 0
Original Bakery Algorithm
Original Bakery Algorithm
Example
P0 P1 P2 P3 P4
0 1 2 2 3
Example
P0 P1 P2 P3 P4
0 0 2 2 3
Example
P0 P1 P2 P3 P4
0 0 0 2 3
Example
P0 P1 P2 P3 P4
0 0 0 0 3
Example
P0 P1 P2 P3 P4
0 0 0 0 0
Conclusion
 The Bakery algorithm offers a strong near-FIFO guarantee.
 The Bakery algorithm works with even weaker registers.

More Related Content

PPTX
Merge sort algorithm
PPT
Bakery algorithm in operating system
PDF
Concurrency control
PPT
Flow & Error Control
PPTX
Pumping lemma
PPTX
Greedy algorithm
PPT
Elliptical curve cryptography
PDF
Methods for handling deadlocks
Merge sort algorithm
Bakery algorithm in operating system
Concurrency control
Flow & Error Control
Pumping lemma
Greedy algorithm
Elliptical curve cryptography
Methods for handling deadlocks

What's hot (20)

PPT
3.8 quicksort
PPT
Chapter 3 - Processes
PPTX
Finite Automata in compiler design
PPTX
Basic Traversal and Search Techniques
PPTX
Critical Section in Operating System
PDF
CNS - Unit - 2 - Stream Ciphers and Block Ciphers
PPTX
Bus aribration
PPT
03 algorithm properties
PPT
PPTX
PPTX
Theory of Computation - Strings and Languages and Proofs (Lecture 2)
PPTX
Deadlock Prevention
PPT
stop and wait
PDF
Unit 3 Dictionary based Compression Techniques
PPTX
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
PPTX
Feistel cipher
PPTX
Hamming code system
PPTX
Knapsack problem using greedy approach
PPTX
SYNCHRONIZATION
PPTX
NFA Converted to DFA , Minimization of DFA , Transition Diagram
3.8 quicksort
Chapter 3 - Processes
Finite Automata in compiler design
Basic Traversal and Search Techniques
Critical Section in Operating System
CNS - Unit - 2 - Stream Ciphers and Block Ciphers
Bus aribration
03 algorithm properties
Theory of Computation - Strings and Languages and Proofs (Lecture 2)
Deadlock Prevention
stop and wait
Unit 3 Dictionary based Compression Techniques
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
Feistel cipher
Hamming code system
Knapsack problem using greedy approach
SYNCHRONIZATION
NFA Converted to DFA , Minimization of DFA , Transition Diagram
Ad

Similar to Bakery Algorithm (20)

PPTX
15- Bakery-Algorithm.pptx
PPTX
Presentation on Bakery Algorithm
PPTX
Bakery algorithm
PPT
Bakery algorithm
PPTX
Bakers and Philosophers
PPT
Process Synchronization
PDF
Turing Lecture - The Computer Science of Concurrency - The Early Years : Notes
PPT
Operating System
PDF
Operating System-Ch6 process synchronization
PPTX
Food Order in a Restaurant - Data Structure Project
DOCX
Adsa u4 ver 1.0
PDF
Ch5 process synchronization
PPT
U3-PPT-1 (1).ppt
KEY
Algorithms are Recipes
PDF
Bankers algorithm
PPT
operating system the critical section problem
PPT
Os module 2 c
PPT
Os module 2 c
PPT
Ch7: Process Synchronization
PPT
Ch7 Process Synchronization galvin
15- Bakery-Algorithm.pptx
Presentation on Bakery Algorithm
Bakery algorithm
Bakery algorithm
Bakers and Philosophers
Process Synchronization
Turing Lecture - The Computer Science of Concurrency - The Early Years : Notes
Operating System
Operating System-Ch6 process synchronization
Food Order in a Restaurant - Data Structure Project
Adsa u4 ver 1.0
Ch5 process synchronization
U3-PPT-1 (1).ppt
Algorithms are Recipes
Bankers algorithm
operating system the critical section problem
Os module 2 c
Os module 2 c
Ch7: Process Synchronization
Ch7 Process Synchronization galvin
Ad

Recently uploaded (20)

PPTX
Welding lecture in detail for understanding
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
composite construction of structures.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Well-logging-methods_new................
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
CH1 Production IntroductoryConcepts.pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
web development for engineering and engineering
Welding lecture in detail for understanding
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Geodesy 1.pptx...............................................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
composite construction of structures.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Well-logging-methods_new................
Operating System & Kernel Study Guide-1 - converted.pdf
Internet of Things (IOT) - A guide to understanding
CH1 Production IntroductoryConcepts.pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Automation-in-Manufacturing-Chapter-Introduction.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Construction Project Organization Group 2.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
UNIT 4 Total Quality Management .pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
bas. eng. economics group 4 presentation 1.pptx
web development for engineering and engineering

Bakery Algorithm