+ return t->status;
+}
+
+/**
+ * Set the notification value of all tasks of a scheduler instance.
+ *
+ * \param s The scheduler instance whose tasks should be notified.
+ * \param err A positive error code.
+ *
+ * This simply iterates over all existing tasks of \a s and sets each
+ * task's notification value to \p -err.
+ */
+void task_notify_all(struct sched *s, int err)
+{
+ struct task *t;
+
+ list_for_each_entry(t, &s->task_list, node)
+ task_notify(t, err);
+}
+
+/**
+ * Set the I/O timeout to the minimal possible value.
+ *
+ * \param s Pointer to the scheduler struct.
+ *
+ * This causes the next poll() call to return immediately.
+ */
+void sched_min_delay(struct sched *s)
+{
+ s->timeout = 0;
+}
+
+/**
+ * Impose an upper bound for the I/O timeout.
+ *
+ * \param to Maximal allowed timeout.
+ * \param s Pointer to the scheduler struct.
+ *
+ * If the current I/O timeout is already smaller than to, this function does
+ * nothing. Otherwise the timeout is set to the given value.
+ *
+ * \sa \ref sched_request_timeout_ms().
+ */
+void sched_request_timeout(struct timeval *to, struct sched *s)
+{
+ long unsigned ms = tv2ms(to);
+ if (s->timeout > ms)
+ s->timeout = ms;
+}
+
+/**
+ * Bound the I/O timeout to at most the given amount of milliseconds.
+ *
+ * \param ms The maximal allowed timeout in milliseconds.
+ * \param s Pointer to the scheduler struct.
+ *
+ * Like \ref sched_request_timeout() this imposes an upper bound on the I/O
+ * timeout.
+ */
+void sched_request_timeout_ms(long unsigned ms, struct sched *s)
+{
+ struct timeval tv;
+ ms2tv(ms, &tv);
+ sched_request_timeout(&tv, s);
+}
+
+/**
+ * Bound the I/O timeout by an absolute time in the future.
+ *
+ * \param barrier Defines the upper bound for the timeout.
+ * \param s Pointer to the scheduler struct.
+ *
+ * \return If the barrier is in the past, this function does nothing and
+ * returns zero. Otherwise it returns one.
+ *
+ * \sa \ref sched_request_barrier_or_min_delay().
+ */
+int sched_request_barrier(struct timeval *barrier, struct sched *s)
+{
+ struct timeval diff;
+
+ if (tv_diff(now, barrier, &diff) > 0)
+ return 0;
+ sched_request_timeout(&diff, s);
+ return 1;
+}
+
+/**
+ * Bound the I/O timeout or request a minimal delay.
+ *
+ * \param barrier Absolute time as in \ref sched_request_barrier().
+ * \param s Pointer to the scheduler struct.
+ *
+ * \return If the barrier is in the past, this function requests a minimal
+ * timeout and returns zero. Otherwise it returns one.
+ *
+ * \sa \ref sched_min_delay(), \ref sched_request_barrier().
+ */
+int sched_request_barrier_or_min_delay(struct timeval *barrier, struct sched *s)
+{
+ struct timeval diff;
+
+ if (tv_diff(now, barrier, &diff) > 0) {
+ sched_min_delay(s);
+ return 0;