Martin,

Change the following line of the code to sleep for 20 sec instead of the
counter(variable i). You will find the penalty to be 10 msec. 

BTW, does the fix proposed to change the kernel with HZ=1000 worked??

Reg
Ved

-----Original Message-----
From: Martin, Stephen [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 06, 2002 12:55 PM
To: '[EMAIL PROTECTED]'
Subject: Why do threads take so long to wake up underlinux


I've been doing some benchmarks on my machine (a dual 733 running redhat
7.2)
and there seems to be a 20 millisecond penalty for doing a sleep or a wait.
Here
is code that illustrates it:

try {
        for (int i = 0; i < 30; i++) {
                long start = System.currentTimeMillis();
                Thread.currentThread().sleep(i);
                long end = System.currentTimeMillis();
                System.out.println("total time = " + (end - start) + " for
sleep(" + i + ")");
        }
} catch (Exception ex) {}

The output i get is

total time = 2 for sleep(0)
total time = 21 for sleep(1)
total time = 20 for sleep(2)
total time = 16 for sleep(3)
total time = 23 for sleep(4)
total time = 19 for sleep(5)
total time = 20 for sleep(6)
total time = 19 for sleep(7)
total time = 20 for sleep(8)
total time = 20 for sleep(9)
total time = 20 for sleep(10)
total time = 29 for sleep(11)
total time = 29 for sleep(12)
total time = 29 for sleep(13)
total time = 29 for sleep(14)
total time = 29 for sleep(15)
total time = 29 for sleep(16)
total time = 26 for sleep(17)
total time = 33 for sleep(18)
total time = 29 for sleep(19)
total time = 29 for sleep(20)
total time = 39 for sleep(21)
total time = 39 for sleep(22)
total time = 39 for sleep(23)
total time = 39 for sleep(24)
total time = 40 for sleep(25)
total time = 39 for sleep(26)
total time = 39 for sleep(27)
total time = 39 for sleep(28)
total time = 39 for sleep(29)

This is pretty much consistent on all jvms that i've tried blackdown, sun
(1.3.x and 1.4) and IBM
and would seem to therefore be an OS issue. Can anyone provide me with more
info on this and is
there a workaround?


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to