login
Header Space

 
 

Re: thread scheduling at mutex unlock

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Xu <davidxu@...>
Cc: <freebsd-stable@...>, Brent Casavant <b.j.casavant@...>, <freebsd-threads@...>
Date: Thursday, May 15, 2008 - 4:48 pm

on 15/05/2008 15:57 David Xu said the following:

David,

did you examine or try the small program that I sent before?
The "lucky" thread slept for 1 second each time it held mutex.
So in total it spent about 8 seconds sleeping and holding the mutex. And 
the "unlucky" thread, consequently, spent 8 seconds blocked waiting for 
that mutex. And it didn't get "lucky".
Yes, technically the "lucky" thread was not running while holding the 
mutex, so probably this is why scheduling algorithm didn't immediately work.

I did more testing and see that the "unlucky" thread eventually gets a 
chance (eventually means after very many lock/unlock cycles), but I 
think that it is penalized too much still.
I wonder if with current code it is possible and easy to make this 
behavior more deterministic.
Maybe something like the following:
if (oldest_waiter.wait_time < X)
    do what we do now...
else
    go into kernel for possible switch

I have very little idea about unit and value of X.


I almost agree. But I still wouldn't take your last statement for a 
fact. "Dreadful performance"  - on micro-scale maybe, not necessarily on 
macro scale.
After all, never switching context would be the best performance for a 
single CPU-bound task, but you wouldn't think that this is the best 
performance for the whole system.

As a data point: it seems that current Linux threading library is not 
significantly worse than libthr, but my small test program on Fedora 7 
works to my expectations.

-- 
Andriy Gapon
_______________________________________________
freebsd-threads@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-threads
To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org"
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
thread scheduling at mutex unlock, Andriy Gapon, (Wed May 14, 11:17 am)
Re: thread scheduling at mutex unlock, Brent Casavant, (Thu May 15, 1:16 am)
Re: thread scheduling at mutex unlock, David Xu, (Thu May 15, 12:22 am)
Re: thread scheduling at mutex unlock, Andriy Gapon, (Thu May 15, 4:35 am)
Re: thread scheduling at mutex unlock, Alfred Perlstein, (Fri May 16, 4:15 pm)
Re: thread scheduling at mutex unlock, Brent Casavant, (Fri May 16, 5:17 pm)
Re: thread scheduling at mutex unlock, Daniel Eischen, (Fri May 16, 5:55 pm)
Re: thread scheduling at mutex unlock, Alfred Perlstein, (Fri May 16, 9:50 pm)
Re: thread scheduling at mutex unlock, Daniel Eischen, (Sat May 17, 1:11 am)
RE: thread scheduling at mutex unlock, David Schwartz, (Thu May 15, 4:25 pm)
Re: thread scheduling at mutex unlock, Brent Casavant, (Thu May 15, 3:51 pm)
Re: thread scheduling at mutex unlock, Andriy Gapon, (Thu May 15, 5:02 pm)
Re: thread scheduling at mutex unlock, Brent Casavant, (Thu May 15, 6:23 pm)
Re: thread scheduling at mutex unlock, Daniel Eischen, (Thu May 15, 9:24 am)
Re: thread scheduling at mutex unlock, Daniel Eischen, (Thu May 15, 1:54 pm)
Re: thread scheduling at mutex unlock, David Xu, (Thu May 15, 5:05 am)
Re: thread scheduling at mutex unlock, Andriy Gapon, (Thu May 15, 5:27 am)
Re: thread scheduling at mutex unlock, David Xu, (Thu May 15, 8:57 am)
Re: thread scheduling at mutex unlock, Andriy Gapon, (Thu May 15, 4:48 pm)
RE: thread scheduling at mutex unlock, David Schwartz, (Wed May 14, 8:29 pm)
Re: thread scheduling at mutex unlock, Andriy Gapon, (Wed May 14, 2:50 pm)
speck-geostationary