Interrupted IO and AWT

Jeff Sturm jsturm@sigma6.com
Tue Mar 21 20:49:00 GMT 2000


On 2000年3月21日, Boehm, Hans wrote:
> It seems to me that a spin lock with exponential back-off (and sleeps for
> longer wait times) doesn't behave that badly, even in this case. There'll
> be some unneeded wakeups on the part of the waiting thread near the
> beginning, and it may sleep for up to about twice as long as it should
> (assuming the base of the exponential is 2). Clearly this is suboptimal in
> this case. But are there cases in which it's a serious problem?

I like that idea, it think it would be worthwhile experimenting with it.
Isn't that essentially what you've already done in your GC anyway (in
linux_threads.c)?
There's a comment in GC_lock that the minimum useable sleep time
for Linux is 2ms. On one system I measured sched_yield() to consume about
4us on a context switch, 1us when no context switch takes place. It could
do perhaps 1000 iterations of test-and-set/yield in that same interval.
You wouldn't want to sleep too early, or most of that 2ms could be
unnecessarily consumed. The current SLEEP_THRESHOLD of 12 in GC_lock
seems low to me.
I'd question if suspend/resume could be any more effective over such a
duration (~1ms). I don't think so, since any other tasks waiting to run
would be given a chance by yielding anyway.
--
Jeff Sturm
jsturm@sigma6.com


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /