Artificial intelligent assistant

What is the "thundering herd" problem and how can a race condition happen even after using spinlocks? From here: > **wait_table** A hash table of wait queues of processes waiting on a page to be freed. This is of importance to wait_on_page() and unlock_page(). While processes could all wait on one queue, this would cause all waiting processes to race for pages still locked when woken up. A large group of processes contending for a shared resource like this is sometimes called a thundering herd. Wait tables are discussed further in Section 2.2.3; What is the "thundering herd" problem and, also, it's mentioned in the page that a spinlock is used, how can a race condition happen even when using spinlocks? Does the number of contending processes really matter? I thought that no matter how many processes are contending, only one process will grab the spinlock and no race condition will occur.

There is no `race condition`, the spinlock ensures this.

The `thundering herd problem` is that when something happens, typically a lock being released or an I/O input event completing, lots of processes which have been waiting will resume. One will be choosen and all the rest will typically resume waiting on the lock or I/O event.

Think about a press conference. When the person giving the briefing finishes one answer all the reporters start trying to attract the attention of the briefer. The briefer chooses one, all the reporters settle down, a question is asked and answered, and then all the reporters try and attract the attention again. This works well with ten reporters but with ten thousand there is a lot of wasted effort of all the reporters trying to attract the attention that could be made more efficient by having a queue of reporters and each asking their question in turn.

So `thundering herd` is about efficiency rather than correctness.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy d00ce068d8f1e87f276ec93393342c31