Lec25-Bakery Algorithm

Lec25-Bakery Algorithm - National University of Computer...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Operating System Operating System Spring 09 Spring 09 National University National University of Computer & Emerging Sciences of Computer & Emerging Sciences Lec25-Bakery Algorithm Lec25-Bakery Algorithm Prepared by Prepared by Uzma Marouf Uzma Marouf [email protected] [email protected]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Reference Reference Modern Operating System Andrew S. Tanenbaum 2 nd edition 2.3 Interprocess communications Operating System Concepts Silberschatz 6 th Edition Chapter 7
Background image of page 2
3 Multiple Process Solutions Multiple Process Solutions Peterson’s solution solves the critical-section problem for two processes, in software For multiple processes we have “Bakery Algorithm” Used in bakeries etc
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Bakery Algorithm Bakery Algorithm The basic idea is that of a bakery On entering the bakery, Customers take tokens Whoever has the lowest token gets service next. “Service" means entry to the critical section.
Background image of page 4
5 Bakery Algorithm Bakery Algorithm int token[n]; token[0] = token given to Process 0 token[1] = token given to Process 1 token[n-1] = token given to Process n – 1
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Algorithm Algorithm while (TRUE) { //1. Receive a token token[OwnID]= max(token[0],token[1],. .,token[n-1] //2. Wait for turn for (OthersID = 0;OthersID<n;OthersID++) while (token[OthersID]!=0 &&(token[OthersID],OthersID)<
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2011 for the course COE 10001 taught by Professor Abad during the Spring '09 term at Alfaisal University.

Page1 / 16

Lec25-Bakery Algorithm - National University of Computer...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online