wait.c (cdd38c5f1ce4398ec58fec95904b75824daab7b5) | wait.c (11c7aa0ddea8611007768d3e6b58d45dc60a19e1) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Generic waiting primitives. 4 * 5 * (C) 2004 Nadia Yvette Chambers, Oracle 6 */ 7#include "sched.h" 8 --- 250 unchanged lines hidden (view full) --- 259 spin_lock_irqsave(&wq_head->lock, flags); 260 if (list_empty(&wq_entry->entry)) 261 __add_wait_queue(wq_head, wq_entry); 262 set_current_state(state); 263 spin_unlock_irqrestore(&wq_head->lock, flags); 264} 265EXPORT_SYMBOL(prepare_to_wait); 266 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Generic waiting primitives. 4 * 5 * (C) 2004 Nadia Yvette Chambers, Oracle 6 */ 7#include "sched.h" 8 --- 250 unchanged lines hidden (view full) --- 259 spin_lock_irqsave(&wq_head->lock, flags); 260 if (list_empty(&wq_entry->entry)) 261 __add_wait_queue(wq_head, wq_entry); 262 set_current_state(state); 263 spin_unlock_irqrestore(&wq_head->lock, flags); 264} 265EXPORT_SYMBOL(prepare_to_wait); 266 |
267void | 267/* Returns true if we are the first waiter in the queue, false otherwise. */ 268bool |
268prepare_to_wait_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state) 269{ 270 unsigned long flags; | 269prepare_to_wait_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state) 270{ 271 unsigned long flags; |
272 bool was_empty = false; |
|
271 272 wq_entry->flags |= WQ_FLAG_EXCLUSIVE; 273 spin_lock_irqsave(&wq_head->lock, flags); | 273 274 wq_entry->flags |= WQ_FLAG_EXCLUSIVE; 275 spin_lock_irqsave(&wq_head->lock, flags); |
274 if (list_empty(&wq_entry->entry)) | 276 if (list_empty(&wq_entry->entry)) { 277 was_empty = list_empty(&wq_head->head); |
275 __add_wait_queue_entry_tail(wq_head, wq_entry); | 278 __add_wait_queue_entry_tail(wq_head, wq_entry); |
279 } |
|
276 set_current_state(state); 277 spin_unlock_irqrestore(&wq_head->lock, flags); | 280 set_current_state(state); 281 spin_unlock_irqrestore(&wq_head->lock, flags); |
282 return was_empty; |
|
278} 279EXPORT_SYMBOL(prepare_to_wait_exclusive); 280 281void init_wait_entry(struct wait_queue_entry *wq_entry, int flags) 282{ 283 wq_entry->flags = flags; 284 wq_entry->private = current; 285 wq_entry->func = autoremove_wake_function; --- 186 unchanged lines hidden --- | 283} 284EXPORT_SYMBOL(prepare_to_wait_exclusive); 285 286void init_wait_entry(struct wait_queue_entry *wq_entry, int flags) 287{ 288 wq_entry->flags = flags; 289 wq_entry->private = current; 290 wq_entry->func = autoremove_wake_function; --- 186 unchanged lines hidden --- |