Index: kernel/generic/src/synch/waitq.c
===================================================================
--- kernel/generic/src/synch/waitq.c	(revision 98000fb4ea6015506f059c9b121e417ce991ecfd)
+++ kernel/generic/src/synch/waitq.c	(revision 057d21af95b6d9e801a14c4a6e6e4a784ad3dfd7)
@@ -171,4 +171,37 @@
 out:
 	spinlock_unlock(&threads_lock);
+	interrupts_restore(ipl);
+}
+
+/** Interrupt the first thread sleeping in the wait queue.
+ *
+ * Note that the caller somehow needs to know that the thread to be interrupted
+ * is sleeping interruptibly.
+ *
+ * @param wq		Pointer to wait queue.
+ */
+void waitq_unsleep(waitq_t *wq)
+{
+	ipl_t ipl;
+
+	ipl = interrupts_disable();
+	spinlock_lock(&wq->lock);
+
+	if (!list_empty(&wq->head)) {
+		thread_t *t;
+		
+		t = list_get_instance(wq->head.next, thread_t, wq_link);
+		spinlock_lock(&t->lock);
+		ASSERT(t->sleep_interruptible);
+		if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
+			t->timeout_pending = false;
+		list_remove(&t->wq_link);
+		t->saved_context = t->sleep_interruption_context;
+		t->sleep_queue = NULL;
+		spinlock_unlock(&t->lock);
+		thread_ready(t);
+	}
+
+	spinlock_unlock(&wq->lock);
 	interrupts_restore(ipl);
 }
