{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lec24-Busy Waiting Algorithms

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

This preview shows pages 1–6. 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 Lec24-Busy waiting Algorithms Lec24-Busy waiting Algorithms Prepared by Prepared by Uzma Maroof Uzma Maroof [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
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();

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

View Full Document
4 Lock Variables Lock Variables Process 1 1.while (FLAG == FALSE); 2.FLAG = FALSE; 4.FLAG = TRUE; 5.noncritical_section(); Process 2 1.while (FLAG == FALSE); 2. Timeout FLAG = TRUE FLAG = FALSE 3.critical_section(); 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
5 Solution: Strict Alternation Solution: Strict Alternation We need to remember “ Who’s turn it is?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}