Lec25-Bakery Algorithm

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

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

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]

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

View Full Document
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
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

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

View Full Document
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.
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

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

View Full Document
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)<
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
Ask a homework question - tutors are online