<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:hahnjo@hahnjo.de" title="Jonas Hahnfeld <hahnjo@hahnjo.de>"> <span class="fn">Jonas Hahnfeld</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - OpenMP tests sometimes deadlock"
   href="https://bugs.llvm.org/show_bug.cgi?id=35731">bug 35731</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - OpenMP tests sometimes deadlock"
   href="https://bugs.llvm.org/show_bug.cgi?id=35731#c19">Comment # 19</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - OpenMP tests sometimes deadlock"
   href="https://bugs.llvm.org/show_bug.cgi?id=35731">bug 35731</a>
              from <span class="vcard"><a class="email" href="mailto:hahnjo@hahnjo.de" title="Jonas Hahnfeld <hahnjo@hahnjo.de>"> <span class="fn">Jonas Hahnfeld</span></a>
</span></b>
        <pre>(In reply to Jonas Hahnfeld from <a href="show_bug.cgi?id=35731#c18">comment #18</a>)
<span class="quote">> I'll have to look up if sched_yield() guarantees you to switch threads [...]</span >

sched_yield() is defined by POSIX [1] and its description says:
<span class="quote">> The sched_yield() function shall force the running thread to relinquish the
> processor until it again becomes the head of its thread list.</span >

"Scheduling Policies"[2] explains that there is one ordered thread list per
priority:
<span class="quote">> There is, conceptually, one thread list for each priority. A runnable thread
> will be on the thread list for that thread's priority.</span >
This matches the description on the Linux man page[3]:
<span class="quote">> sched_yield() causes the calling thread to relinquish the CPU. The thread is
> moved to the end of the queue for its static priority and a new thread gets
> to run.</span >

A thread's priority can be changed with calls to
 - pthread_setschedparam(), pthread_setschedprio()
 - sched_setscheduler(), sched_setparam()
 - apparently also setpriority()
The OpenMP runtime only calls sched_setscheduler() for the monitor thread
(disabled by default), but does not change the priority for the OpenMP worker
threads. I think this means that all OpenMP threads have the same (default)
priority and are therefore in the same thread list.
My conclusion would be that the PDS scheduler and thus any system using it are
not confirming to the POSIX standard. From an upstream perspective I'm closing
this bug as INVALID because there is nothing we can do in the library which
assumes to run on a POSIX system.

[1] <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_yield.html">http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_yield.html</a>
[2]
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_08_04_01">http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_08_04_01</a>
[3] <a href="http://man7.org/linux/man-pages/man2/sched_yield.2.html">http://man7.org/linux/man-pages/man2/sched_yield.2.html</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>