Re: How to count the context switches times
Haitao wrote:
Thanks!
Your use of inline-and-trim posting instead of top-posting will convey your
gratitude sufficiently.
"Patricia Shanahan" wrote:
In any case I suspect that yield is far from the most significant cause
of context switches. What about becoming non-runnable due to waiting for
a monitor, for I/O, or for a lock wait? Or losing the processor due to
the operating system deciding that some other thread needs it more?
Haitao wrote:
My understanding is that context swithes still exist between two threads
with the same priority, even though there are no blocking codes in each
thread. JVM may use a round-robin algorithm to schedule these threads (That
would be the case of one thread "losing the processor due to the operating
system deciding that some other thread needs it more")
Doesn't "round-robin" mean "doesn't give up the time slice until it blocks"?
Even if not, that is a permissible strategy for the JVM to use in thread
scheduling.
I know that some real-time operating systems (say, VxWorks) provide some
hook functions that will be invoked when a context switch occurs, but I
don't know whether Java (JVM) provides similar functions.
I have not heard of such.
Most Java implementations are not real-time. Most involve the OS in the
actual thread implementation.
--
Lew