리눅스에서 pthread API 사용에 관한 질문입니다.
글쓴이: trymp / 작성시간: 금, 2011/06/03 - 8:15오후
리눅스 환경에서 multi thread 프로그램을 짜고자 합니다.
pthread API 사용하는데 있어서 고민이 있습니다.
아래 3가지 경우인데요..
1. pthread_cond_signal() 할 경우 받는 thread 가 pthread_cond_wait() 상태가 아닌 경우
어떤 오작동의 가능성이 있는지요??
2. pthread_cond_wait() 를 사용하다 보니, signal 하지 않았는데도 불구하고
return 이 되는 경우가 간혹 생겼습니다. 이런 경우도 있나요??
3. thread 간 작업 동기화에서 condition value 외에 pthread_barrier 도 쓰인다고 들었습니다.
구체적인 차이점이 무었인지 궁금합니다.
고수님들의 조언 부탁드립니다.
Forums:
1. 그냥 무시됩니다. 2. 네
1. 그냥 무시됩니다.
2. 네 있습니다.
pthread_cond_wait()의 man page에서 말하듯이, 정말 올바른 waken up 이었는지 확인할수있는 수단을 마련해야합니다.
When using condition variables there is always a Boolean predicate involving shared variables associated with each condition wait that is true if the thread should proceed. Spurious wakeups from the pthread_cond_timedwait() or pthread_cond_wait() functions may occur. Since the return from pthread_cond_timedwait() or pthread_cond_wait() does not imply anything about the value of this predicate, the predicate should be re-evaluated upon such return.
3. http://nptl.bullopensource.org/Trace/example.html
댓글 달기