Lec24-Busy Waiting Algorithms

Lec24-Busy Waiting Algorithms - National University of...

Info iconThis preview shows pages 1–6. 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 Lec24-Busy waiting Algorithms Lec24-Busy waiting Algorithms Prepared by Prepared by Uzma Maroof Uzma Maroof uzma.maroof@nu.edu.pk uzma.maroof@nu.edu.pk
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
Background image of page 2
3 Before entering a critical section a process should know if any other is already in the critical section or not Consider having a FLAG (also called lock) FLAG = TRUE No process is in the critical section FLAG = FALSE A process is in the critical section Lock Variables: Software Solution Lock Variables: Software Solution // wait while someone else is in the // critical region 1. while (FLAG == FALSE); // stop others from entering critical region 2. FLAG = FALSE; 3. critical_section(); // after critical section let others enter //the critical region 4. FLAG = TRUE; 5. noncritical_section();
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 Lock Variables Lock Variables Process 1 1.while (FLAG == FALSE); 2.FLAG = FALSE; 4.FLAG = TRUE; Process 2 1.while (FLAG == FALSE); 2. Timeout Process 2 Busy Waits FLAG = TRUE FLAG = FALSE 2.FLAG = FALSE; No two processes may be simultaneously inside their critical sections Process 2 ‘s Program counter is at Line 2 3.critical_section(); Process 1 forgot that it was Process 2’s turn
Background image of page 4
5 Solution: Strict Alternation Solution: Strict Alternation We need to remember “ Who’s turn it is?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

Lec24-Busy Waiting Algorithms - National University of...

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

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