Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6512687

Bug #4813310 (Linux thread priority support) marked as Closed, fixed but is not.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 6
    • hotspot
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.16-2-686 #1 Sat Jul 15 21:59:21 UTC 2006 i686 GNU/Linux (Debian)

      A DESCRIPTION OF THE PROBLEM :
      Bug report 4813310 indicates that thread priority support has been added to the Hotspot JVM when run as root under linux, so long as the -XX:ThreadPriorityPolicy=1 option is supplied. This is not true.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Source code below is compiled, and run as root with

      java -XX:ThreadPriorityPolicy=1 ThreadTester

      as advised in bug #4813310.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Once the high priority thread is started, the Thread.yield() statement should have no effect, as the high priority thread remains runnable for the duration of its life. The low priority thread should only be able to complete once the high priority thread has completed output.

      This behaviour is observed on Windows but not Linux.
      ACTUAL -
      On Linux, the output from the two threads are interleaved, so Thread.yield() is not behaving as described in the API documentation.

      Even if the Thread.yield() command is removed, then the low priority thread is still able to periodically interrupt the high priority thread.

      The impact on us is that time-critical IO responses are being delayed by garbage collection and other housekeeping processes, causing our application to break.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class ThreadTester implements Runnable {

              int priority;

              public void run() {
                      Thread.currentThread().setPriority(priority);
                      for(int i=0; i<50000; i++) {
                              System.out.println(priority+" "+i);
      //Optionally yield
                              Thread.yield();
                      }
                      System.out.println(priority+" done.");
              }

              public static void main(String[] args) {
                      ThreadTester low=new ThreadTester();
                      low.priority=Thread.MIN_PRIORITY;

                      ThreadTester high=new ThreadTester();
                      high.priority=Thread.MAX_PRIORITY;

                      Thread tlow=new Thread(low);
                      Thread thigh=new Thread(high);

                      System.out.println("Executing Low");

                      tlow.start();

                      System.out.println("Sleeping");

                      try {
                              Thread.sleep(20);
                      } catch (InterruptedException ie) {

                      }

                      System.out.println("Executing high");
                      thigh.start();
              }
      }

      ---------- END SOURCE ----------

            dholmes David Holmes
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: