race condition
-
[OS] Synchronization과 Critical-Section ProblemCS/Operating System 2021. 12. 1. 18:50
🔍 Background process synchronization이 필요한 이유! ❗️ 다수의 프로세스/스레드가 공유 데이터에 동시(concurency -> single core), 병렬(parallel -> multicore) 접근으로 인한 데이터 불일치(inconsistency)가 발생할 수 있다. Example - Producer-Consumer problem Producer: 데이터 생성 스레드 Consumer: 데이터 소비 스레드 👉 이 두 스레드는 같은 데이터를 생산하고 소비하는 스레드이기 때문에 반드시 동기화되어야 한다!!! 두 thread가 각각 이러한 코드를 가지고 있다고 생각해보자. global variable로 선언되어 있는 counter 변수는 두 thread가 공유하는 변수이다. ..