본문 바로가기

Concurrency

Critical Section & Race Condition

Critical Section

Critical Section 은 여러개의 thread 에 의해 data 나 resource 가 공유되는 부분을 일컫는다.

 

Race Condition

Race Condition 은 thread 가 동기화 되어 있지 않은 상태에서 critical section 영역을 여러 thread 들이 실행할때 발생한다.

 

thread 들은 shared section 을 통해 shared resource 를 읽거나 쓰는 “race” 를 수행하며 각 thread 들이 race 를 끝내는 순서대로 출력을 하게 된다.

 

Race Condition 상황에서는 thread 가 다른 thread 가 접근하고 있는 공유된 자원이나 변수에 접근을 하게 되므로, data 의 일관성이 깨지게 된다.

'Concurrency' 카테고리의 다른 글

Mutex vs Semaphore  (0) 2024.04.13
Deadlock, liveness, Live lock, Starvation  (0) 2024.04.13
뮤텍스(Mutex) VS 모니터(Monitor)  (0) 2021.03.28