Open Yunhee000 opened 7 months ago
bool Test_and_Set(bool target) { bool rv = target; target = true; return rv; }
하드웨어적으로 test & modify를 atomic하게 수행할 수 있도록 지원 -> 데이터를 읽어가는 것과 저장하는 것 모두 한꺼번에 수행
do { while (Test_and_Set(lock)); critical section lock = false; remainder section } whlie (1);
=> lock이 false이면 아무도 critical section에 들어가지 않음
Test_and_Set 코드
Synchronization Hardware
하드웨어적으로 test & modify를 atomic하게 수행할 수 있도록 지원 -> 데이터를 읽어가는 것과 저장하는 것 모두 한꺼번에 수행
=> lock이 false이면 아무도 critical section에 들어가지 않음