Comments (5)
제가 책을 중심으로 내용을 구성하다보니 이런 부분을 미처 보지 못한 것 같네요.
저도 올려주신 것을 보고레퍼런스를 검색 해봤는데, wait(lck, pred)
와 같은 호출은 아래와 같이 동작한다고 합니다.
while (!pred()) {
wait(lock);
}
이런 코드라면 말씀하신대로 동작하는 이유를 알 수 있을 것 같네요.
http://en.cppreference.com/w/cpp/thread/condition_variable/wait
from cppconcurrencyinaction.
레퍼런스 봤었는데 자세히 안봐서 그냥 지나쳤네요 ㅠ_ㅠ
네 luncliff 님이 올려주신대로 pred 검사 하고 wait 으로 들어 가기때문에 2번 항목이 문제가 안됩니다.
from cppconcurrencyinaction.
wait 함수에 pred 함수를 넘겨 주면 Spurious Wakeup 이 나타나지 않을수 있지 않을까요?
wait 에서 block 이 풀렸지만 다시 pred 조건을 확인하니깐요?
from cppconcurrencyinaction.
아, 늦게 봤네요.
spurious wakeup 자체를 프로그램에서 막을 방법은 없으니, 혹시나 활성화 되더라도 predicate를 검사해서 '안전하게' 다시 잠들도록 하는 방법이라고 생각되네요.
from cppconcurrencyinaction.
충분히 공유 되었을거라 생각하고 닫겠습니다.
from cppconcurrencyinaction.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cppconcurrencyinaction.