https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1709775478
2008-12-05T21:14:33Z
Ruby Issue Tracking System
Ruby master - Bug #812: Failure: test_priority (TestThread) on mswin32
https://bugs.ruby-lang.org/issues/812?journal_id=1869
2008-12-05T21:14:33Z
ko1 (Koichi Sasada)
<ul><li><strong>Assignee</strong> set to <i>ko1 (Koichi Sasada)</i></li></ul><p>=begin</p>
<p>=end</p>
Ruby master - Bug #812: Failure: test_priority (TestThread) on mswin32
https://bugs.ruby-lang.org/issues/812?journal_id=10166
2010-04-14T00:44:30Z
mame (Yusuke Endoh)
mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>ko1 (Koichi Sasada)</i> to <i>mame (Yusuke Endoh)</i></li><li><strong>Target version</strong> set to <i>1.9.2</i></li><li><strong>ruby -v</strong> set to <i>-</i></li></ul><p>=begin<br>
遠藤です。</p>
<p>2008年12月3日12:46 U.Nakamura <a href="mailto:usa@garbagecollect.jp" class="email">usa@garbagecollect.jp</a>:</p>
<blockquote>
<p>表題の通りですが、priorityの低いスレッドの選択率を下げる機構<br>
はpthreadでもwin32でも同じなのに、win32だとまともに機能してい<br>
ないように見えるのはなぜでしょうか?</p>
</blockquote>
<p>この機構は、native_thread_yield() を呼んだときに極力他のスレッドに<br>
コンテキストスイッチしてくれないと働きません。<br>
thread_win32.c では native_thread_yield() は Sleep(0) となっていて、<br>
Sleep(0) は MSDN によると</p>
<blockquote>
<p>中断時間として 0ms を指定してこの関数を呼び出すと、現在のスレッドは<br>
自らに割り当てられているタイムスライスの残りの部分を放棄します。</p>
</blockquote>
<p>らしいので、これが本当なら動きそうなものですが、どうなんでしょうね。</p>
<p>いずれにしても、このテストはプラットフォームとタイミングに強く依存<br>
するのであまり適切でなかったかもしれません。すでになかださんによって<br>
コメントアウトされているので、解決していると思います。</p>
<p>Thread#priority, #priority= の rdoc は、高優先度のスレッドがいる限り<br>
低優先度のスレッドが全く実行されないかのように読めるので、これを修正<br>
しつつ、プラットフォームによっては無視されるということを書いて、この<br>
チケットはクローズします。</p>
<p>diff --git a/thread.c b/thread.c<br>
index 10d6047..40a3483 100644<br>
--- a/thread.c<br>
+++ b/thread.c<br>
@@ -2142,8 +2142,11 @@ rb_thread_keys(VALUE self)<br>
*</p>
<ul>
<li>Returns the priority of <i>thr</i>. Default is inherited from the</li>
<li>current thread which creating the new thread, or zero for the</li>
</ul>
<ul>
<li>
<ul>
<li>initial main thread; higher-priority threads will run before</li>
</ul>
</li>
<li>
<ul>
<li>lower-priority threads.</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>initial main thread; higher-priority thread will run more frequently</li>
</ul>
</li>
<li>
<ul>
<li>than lower-priority threads (but lower-priority threads can also run).</li>
</ul>
</li>
<li>
<ul>
<li>
</ul>
</li>
<li>
<ul>
<li>This is just hint for Ruby thread scheduler. It may be ignored on some</li>
</ul>
</li>
<li>
<ul>
<li>platform.</li>
<li>
<li>
<pre><code>Thread.current.priority #=> 0
</code></pre>
</li>
</ul>
*/<br>
@@ -2162,7 +2165,11 @@ rb_thread_priority(VALUE thread)
<ul>
<li>
<pre><code>thr.priority= integer => thr
</code></pre>
</li>
<li>
<li>Sets the priority of <i>thr</i> to <i>integer</i>. Higher-priority threads</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>will run before lower-priority threads.</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>will run more frequently than lower-priority threads (but lower-priority</li>
</ul>
</li>
<li>
<ul>
<li>threads can also run).</li>
</ul>
</li>
<li>
<ul>
<li>
</ul>
</li>
<li>
<ul>
<li>This is just hint for Ruby thread scheduler. It may be ignored on some</li>
</ul>
</li>
<li>
<ul>
<li>platform.</li>
<li>
<li>
<pre><code>count1 = count2 = 0
</code></pre>
</li>
<li>
<pre><code>a = Thread.new do
</code></pre>
</li>
</ul>
</li>
</ul>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a><br>
=end</p>
Ruby master - Bug #812: Failure: test_priority (TestThread) on mswin32
https://bugs.ruby-lang.org/issues/812?journal_id=10175
2010-04-14T10:09:42Z
usa (Usaku NAKAMURA)
usa@garbagecollect.jp
<ul></ul><p>=begin<br>
こんにちは、なかむら(う)です。</p>
<p>In message "<a href="https://blade.ruby-lang.org/ruby-dev/40977">[ruby-dev:40977]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Failure: test_priority (TestThread) on mswin32 (Closed)" href="https://bugs.ruby-lang.org/issues/812">#812</a>] Failure: test_priority (TestThread) on mswin32"<br>
on Apr.14,2010 00:44:30, <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> wrote:</p>
<blockquote>
<blockquote>
<p>表題の通りですが、priorityの低いスレッドの選択率を下げる機構<br>
はpthreadでもwin32でも同じなのに、win32だとまともに機能してい<br>
ないように見えるのはなぜでしょうか?</p>
</blockquote>
<p>この機構は、native_thread_yield() を呼んだときに極力他のスレッドに<br>
コンテキストスイッチしてくれないと働きません。<br>
thread_win32.c では native_thread_yield() は Sleep(0) となっていて、<br>
Sleep(0) は MSDN によると</p>
<blockquote>
<p>中断時間として 0ms を指定してこの関数を呼び出すと、現在のスレッドは<br>
自らに割り当てられているタイムスライスの残りの部分を放棄します。</p>
</blockquote>
<p>らしいので、これが本当なら動きそうなものですが、どうなんでしょうね。</p>
</blockquote>
<p>もちろん本当なので動きそうなのですが、なんでだろう、というの<br>
が未だに謎です。</p>
<blockquote>
<p>Thread#priority, #priority= の rdoc は、高優先度のスレッドがいる限り<br>
低優先度のスレッドが全く実行されないかのように読めるので、これを修正<br>
しつつ、プラットフォームによっては無視されるということを書いて、この<br>
チケットはクローズします。</p>
</blockquote>
<p>それでいいと思います。</p>
<a name="それでは"></a>
<h2 >それでは。<a href="#それでは" class="wiki-anchor">¶</a></h2>
<p>U.Nakamura <a href="mailto:usa@garbagecollect.jp" class="email">usa@garbagecollect.jp</a></p>
<p>=end</p>
Ruby master - Bug #812: Failure: test_priority (TestThread) on mswin32
https://bugs.ruby-lang.org/issues/812?journal_id=10209
2010-04-15T22:45:40Z
mame (Yusuke Endoh)
mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>=begin</p>
<p>=end</p>