Messages in this thread | | | From | "Stephen C. Tweedie" <> | Date | Mon, 26 Apr 1999 18:09:03 +0100 (BST) | Subject | Re: Linus on Linux, Apache and Threads |
| |
Hi,
On Sat, 24 Apr 1999 18:43:52 -0400 (EDT), Chuck Lever <cel@monkey.org> said:
> this is sounding more complicated by the minute. you also want to tune > this so that you have just the right number of threads active to keep the > L1/L2 caches working at their most efficient. is there any guarantee that > waiting in accept() won't cause round-robin behavior rather than just > picking the first couple of threads on the list?
The default behaviour should be at least reasonable. If you have multiple threads in accept, then yes, you'll get thundering herd in the kernel: all threads in wait_for_connect() will be made runnable. However, the scheduler will prefer to actually schedule those threads which are already on the best CPU, so those threads will tend to be the ones which win the accept(). The other threads will get scheduled later and will either find another connection ready to be accepted, or will sleep again without ever leaving the accept syscall.
Doing a real wake-one is more difficult, but sysV ipc semaphores should at least avoid thundering herd. If you have one demutiplexor thread adding work to a queue and waking up worker threads by up()ing a sysV semaphore, exactly one thread at a time will be woken up. That _will_ be done in strict FIFO, however, but if you have multiple CPUs idle at the time the thread will end up being scheduled on its last CPU (assuming it was last run on one of the idle processors).
--Stephen
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |