]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - sched.c
sched: Introduce task_status().
[paraslash.git] / sched.c
diff --git a/sched.c b/sched.c
index 1b83b704fb48599d7c44ba540bc90b90e040be9b..fb0d4d63eacda82cb4e0779d72daa56c2634a324 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -315,6 +315,25 @@ int task_get_notification(const struct task *t)
        return t->notification;
 }
 
+/**
+ * Return the status value of a task.
+ *
+ * \param t The task to get the status value from.
+ *
+ * \return Zero if task does not exist, one if task is running, negative error
+ * code if task has terminated.
+ */
+int task_status(const struct task *t)
+{
+       if (!t)
+               return 0;
+       if (t->dead)
+               return 0;
+       if (t->error >= 0)
+               return 1;
+       return t->error;
+}
+
 /**
  * Set the notification value of all tasks of a scheduler instance.
  *