Peterson's Solution

    [운영체제/OS] Synchronization_동기화, 임계 구역 문제

    동기화(Synchronization) Producer (=master): 데이터 생성 while(TRUE) { //produce an item and put into the buffer while(counter==BUFFER_SIZE) //is buffer full? ; //do nothing //busy waiting. spin lock buffer[in] = nextProduced;//write연산 (차있지 x경우) in = (in+1) % BUFFER_SIZE; counter++; } Consumer while(TRUE) { while(counter == 0) //is buffer empty? ; //do nothing nextConsumed = buffer[out]; out = (out+1) % ..