반응형
상호 배제 (Mutual Exclusion)) 알고리즘인 Peterson 알고리즘은 다음과 같다.
Process#1 |
Process#2 |
Flag1 = true; Turn = 1; while(Flag2==true && Turn==1) { // busy wait } // Start of Critical Section ... ... // End of Critical Section Flag1 = false; |
Flag2 = true; Turn = 0; while(Flag1==true && Turn==0) { // busy wait } // Start of Critical Section ... ... // End of Critical Section Flag2 = false; |
위와 같은 Peterson 알고리즘은 2개의 프로세스에서만 적용되지만, 2개 이상의 프로세스로 확장할 수도 있다.
Peterson 알고리즘은 Busy Wait이 있는 단점이 있다.
반응형
'컴퓨터공학' 카테고리의 다른 글
PHP (Hypertext Preprocessor) (0) | 2017.09.20 |
---|---|
세마포어 (Semaphore) 란? (0) | 2017.09.20 |
상호 배제 알고리즘 - Dekker 알고리즘 (0) | 2017.09.19 |
상호 배제 (Mutual Exclusion) (0) | 2017.09.19 |
[아두이노] char 배열을 String으로 변환하는 방법 (0) | 2017.09.18 |
댓글