atom feed65 messages in org.freebsd.freebsd-smpRe: SMP meeting summary
FromSent OnAttachments
Jason EvansJun 24, 2000 11:56 pm 
Daniel EischenJun 25, 2000 6:58 am 
Terry LambertJun 25, 2000 10:12 am 
Terry LambertJun 25, 2000 10:36 am 
Julian ElischerJun 25, 2000 10:41 am 
Poul-Henning KampJun 25, 2000 11:07 am 
Nate WilliamsJun 25, 2000 9:41 pm 
Frank MayharJun 25, 2000 11:27 pm 
Frank MayharJun 25, 2000 11:31 pm 
Luoqi ChenJun 26, 2000 9:46 am 
Arun SharmaJun 26, 2000 9:47 am 
Jason EvansJun 26, 2000 11:06 am 
Matthew DillonJun 26, 2000 12:26 pm 
Matthew DillonJun 26, 2000 12:48 pm 
John SconiersJun 26, 2000 12:56 pm 
Matthew DillonJun 26, 2000 1:07 pm 
Luoqi ChenJun 26, 2000 1:13 pm 
Doug RabsonJun 26, 2000 1:26 pm 
Jason EvansJun 26, 2000 2:56 pm 
Jason EvansJun 26, 2000 3:14 pm 
Daniel EischenJun 26, 2000 4:59 pm 
Luoqi ChenJun 26, 2000 7:14 pm 
Jason EvansJun 26, 2000 7:55 pm 
Joe EykholtJun 26, 2000 8:09 pm 
Greg LeheyJun 27, 2000 8:00 pm 
Jason EvansJun 27, 2000 8:25 pm 
Daniel EischenJun 27, 2000 8:26 pm 
Greg LeheyJun 27, 2000 9:59 pm 
Greg LeheyJun 27, 2000 10:11 pm 
Terry LambertJun 28, 2000 4:15 pm 
Terry LambertJun 28, 2000 4:18 pm 
Terry LambertJun 28, 2000 4:37 pm 
Terry LambertJun 28, 2000 4:51 pm 
Arun SharmaJun 28, 2000 9:43 pm 
Greg LeheyJul 2, 2000 7:15 pm 
Daniel EischenJul 3, 2000 3:23 am 
Greg LeheyJul 3, 2000 3:30 am 
Jeroen C. van GelderenJul 3, 2000 7:55 am 
Chuck PatersonJul 3, 2000 8:28 am 
Chuck PatersonJul 3, 2000 8:47 am 
Frank MayharJul 3, 2000 8:49 am 
Greg LeheyJul 3, 2000 4:08 pm 
David ScheidtJul 3, 2000 4:35 pm 
Joe EykholtJul 3, 2000 4:47 pm 
Greg LeheyJul 3, 2000 4:52 pm 
Joe EykholtJul 3, 2000 4:58 pm 
Greg LeheyJul 3, 2000 5:26 pm 
Joe EykholtJul 3, 2000 5:41 pm 
Chuck PatersonJul 3, 2000 7:17 pm 
Daniel EischenJul 3, 2000 7:25 pm 
Daniel EischenJul 3, 2000 7:35 pm 
Greg LeheyJul 3, 2000 7:39 pm 
Daniel EischenJul 3, 2000 7:41 pm 
Chuck PatersonJul 3, 2000 8:40 pm 
Alfred PerlsteinJul 3, 2000 10:08 pm 
Greg LeheyJul 3, 2000 10:37 pm 
Peter WemmJul 4, 2000 2:43 pm 
Greg LeheyJul 4, 2000 3:58 pm 
Peter WemmJul 4, 2000 4:06 pm 
Terry LambertJul 5, 2000 3:38 pm 
Terry LambertJul 5, 2000 4:00 pm 
Terry LambertJul 5, 2000 4:06 pm 
Terry LambertJul 5, 2000 4:10 pm 
Alfred PerlsteinJul 5, 2000 4:29 pm 
Terry LambertJul 6, 2000 4:50 pm 
Subject:Re: SMP meeting summary
From:Greg Lehey (gr@lemis.com)
Date:Jul 3, 2000 5:26:43 pm
List:org.freebsd.freebsd-smp

On Monday, 3 July 2000 at 16:59:09 -0700, Joe Eykholt wrote:

Joe Eykholt wrote:

Greg Lehey wrote:

There's nothing to say that wake_one is more complex. wake_one takes the first process on the mutex's sleep list and wakes it. wake_all (or whatever) would make a loop out of that wake function and wake all the processes on the list. All would then be scheduled, try to take the mutex, and all except one would fail and be put back on the sleep list. Does this make sense?

With adaptive mutexes, the threads which are woken will either run one serially on one CPU, or some run at the same time on multiple CPUs. In that case, one gets the lock right away, and the rest SPIN on it (as long as the new owner doesn't get suspended on something else). They don't necessarily go back to sleep on that same lock.

Another thing that would happen if you don't wake all the waiters, and you have a lot of CPUs, is that a thread that comes along and wants the lock while the new owner is running (or before it's started running) either SPINs or acquires the lock in front of all of the threads that are still asleep. In other words it cuts in line.

I need to look at the implementation more carefully. My understanding is that the mutexes allow exactly one process to run, independent of the number of processors (or any other resource on which they're waiting). If we can allow multiple (but a finite number of) processes to run concurrently, then we should be using counting semaphores (which are, in fact, very similar to sleeping mutexes).

I guess that could be bad for certain locks and for a very large number of CPUs.

You'll always find good and bad examples. It's difficult to generalize.

If you do wake_all, then they all get the same chance at the lock ... and likely they'll just spin for a short time (at worst) if locks are held briefly.

If we have a certain number of slots available, then we wake that many. Normally, though, if you're sleeping at all, you've used up all your slots. Consider a counting semaphore which allows four concurrent processes to enter. Initially the counter is set to 4.

- process 1 takes semaphore. Counter goes to 3. - process 2 takes semaphore. Counter goes to 2. - process 3 takes semaphore. Counter goes to 1. - process 4 takes semaphore. Counter goes to 0. - process 5 tries to take semaphore. Counter goes to -1, so process 5 sleeps. - process 6 tries to take semaphore. Counter is -1, so process 6 sleeps. - process 2 releases semaphore. Counter goes to 0. It's still not > 0, so nothing further happens. - process 1 releases semaphore. Counter goes to 1. Process 5 gets scheduled, decreasing counter to 0.

I'm making assumptions about the exact counter implementation and that process 5 gets scheduled, and not process 6, but they're not relevant to the discussion. Clearly at this point, it wouldn't make any sense to try to schedule process 6, since the counter won't allow it. Things might be slightly different if:

- process 1 releases semaphore. Counter goes to 1. *interrupt* - process 3 releases semaphore. Counter goes to 2. Process 5 gets scheduled, decreasing counter to 1. *return from interrupt* - Counter is 1, so process 6 gets scheduled, decreasing the counter to 0.

Clearly at this point, if we had a process 7 waiting on the queue, it wouldn't make any sense to have it scheduled too.

Greg

To Unsubscribe: send mail to majo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message