login
Header Space

 
 

RE: thread scheduling at mutex unlock

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

> Brent, David,

You are correct, but fairness is not the goal, performance is. If you want
fairness, you are welcome to code it. But threads don't file union
grievances, and it would be absolute foolishness for a scheduler to
sacrifice performance to make threads happier.

The scheduler decides which thread runs, you decide what the running thread
does. You are expected to use your control over that latter part to exercise
whatever your application notion of "fairness" is.

Your test program is a classic example of a case where the use of a mutex is
inappropriate.


Nonsense. The worker thread would be doing work most of the time and
wouldn't be holding the mutex.


So what? The feeder thread could get the mutex after the mutex is unlocked
before the worker thread goes to do work. The only reason your test code
encountered a "problem" was because you yielded the CPU while you held the
mutex and never used up a timeslice.


Nope. You have to create a situation where the mutex is held much more often
than not held to get this behavior. That's a pathological case where the use
of a mutex is known to be inappropriate.


If you want queued locks, feel free to code them and use them. But you have
to work very hard to create a case where they are useful. If you find you're
holding the mutex more often than not, you're doing something *very* wrong.

DS


_______________________________________________
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