[#41278] [BUG:1.9] BINARY should not be ASCII-compatible — Yugui <yugui@...>

WXVndWkbJEIkRyQ5ISMbKEIKCgo+IBskQiRHISIkKiQqJGAkTSQzJDMkXiRHJE41RE9AJEclKyVQ

15 messages 2010/05/11

[#41407] [Bug #3339] win32ole test failure — Usaku NAKAMURA <redmine@...>

Bug #3339: win32ole test failure

20 messages 2010/05/25
[#41411] Re: [Bug #3339] win32ole test failure — Masaki Suketa <masaki.suketa@...> 2010/05/25

助田です。

[#41412] Re: [Bug #3339] win32ole test failure — "U.Nakamura" <usa@...> 2010/05/25

こんにちは、なかむら(う)です。

[ruby-dev:41194] Re: MonitorMixin::ConditionVariable#wait timeout

From: Yusuke ENDOH <mame@...>
Date: 2010-05-06 12:30:28 UTC
List: ruby-dev #41194
遠藤です。

2010年5月6日20:58 Tanaka Akira <akr@fsij.org>:
> たとえ wait が ETIMEDOUT で返って来たとしても、
> signal されていないことは保証されないのではないかと思うんですがどうでしょう?
>
> wait がタイムアウトで諦めた後、mutex をロックする前に、
> 他のスレッドにコンテキストスイッチして signal が起こることは無いんでしょうか。

少なくとも pthread では保証されていません。例の pthread の RATIONALE にも

  Similarly, when pthread_cond_timedwait() returns with the timeout error,
  the associated predicate may be true due to an unavoidable race between
  the expiration of the timeout and the predicate state change.

  The application needs to recheck the predicate on any return because it
  cannot be sure there is another thread waiting on the thread to handle
  the signal, and if there is not then the signal is lost. The burden is
  on the application to check the predicate.

と、ETIMEOUT かどうかに関わらず predicate はチェックしろ、とあります。


> もし有るとすると、ETIMEDOUT でリトライすると、寝てしまって永久に起きない、
> という上記で懸念されている状況に結局なり得るのではないかと思うんですが。

このように ETIMEOUT は CV#wait の誤った使い方を推奨しかねない物なので、
私も #2629 で最初は反対していました。それでも「ないとまずい」ことがない
のかどうか自信がありません。自信がないなら、pthread_cond_timedwait に
倣って返しておくのがいいかな、と思います。

ほんとスレッドは難しいですね。

-- 
Yusuke Endoh <mame@tsg.ne.jp>

In This Thread