diff options
Diffstat (limited to 'kernel/sched/wait.c')
-rw-r--r-- | kernel/sched/wait.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c index 4d2ea6f25568..b8c84c6dee64 100644 --- a/kernel/sched/wait.c +++ b/kernel/sched/wait.c | |||
@@ -242,6 +242,45 @@ long prepare_to_wait_event(wait_queue_head_t *q, wait_queue_t *wait, int state) | |||
242 | } | 242 | } |
243 | EXPORT_SYMBOL(prepare_to_wait_event); | 243 | EXPORT_SYMBOL(prepare_to_wait_event); |
244 | 244 | ||
245 | /* | ||
246 | * Note! These two wait functions are entered with the | ||
247 | * wait-queue lock held (and interrupts off in the _irq | ||
248 | * case), so there is no race with testing the wakeup | ||
249 | * condition in the caller before they add the wait | ||
250 | * entry to the wake queue. | ||
251 | */ | ||
252 | int do_wait_intr(wait_queue_head_t *wq, wait_queue_t *wait) | ||
253 | { | ||
254 | if (likely(list_empty(&wait->task_list))) | ||
255 | __add_wait_queue_tail(wq, wait); | ||
256 | |||
257 | set_current_state(TASK_INTERRUPTIBLE); | ||
258 | if (signal_pending(current)) | ||
259 | return -ERESTARTSYS; | ||
260 | |||
261 | spin_unlock(&wq->lock); | ||
262 | schedule(); | ||
263 | spin_lock(&wq->lock); | ||
264 | return 0; | ||
265 | } | ||
266 | EXPORT_SYMBOL(do_wait_intr); | ||
267 | |||
268 | int do_wait_intr_irq(wait_queue_head_t *wq, wait_queue_t *wait) | ||
269 | { | ||
270 | if (likely(list_empty(&wait->task_list))) | ||
271 | __add_wait_queue_tail(wq, wait); | ||
272 | |||
273 | set_current_state(TASK_INTERRUPTIBLE); | ||
274 | if (signal_pending(current)) | ||
275 | return -ERESTARTSYS; | ||
276 | |||
277 | spin_unlock_irq(&wq->lock); | ||
278 | schedule(); | ||
279 | spin_lock_irq(&wq->lock); | ||
280 | return 0; | ||
281 | } | ||
282 | EXPORT_SYMBOL(do_wait_intr_irq); | ||
283 | |||
245 | /** | 284 | /** |
246 | * finish_wait - clean up after waiting in a queue | 285 | * finish_wait - clean up after waiting in a queue |
247 | * @q: waitqueue waited on | 286 | * @q: waitqueue waited on |