]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - sched.c
get_task_list(): construct a more detailed list
[paraslash.git] / sched.c
diff --git a/sched.c b/sched.c
index 9356dd0c4d14be11fb1284eae7227a8489acf907..bd98a51593593f4f345de376eee137bb7ac8a44b 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -106,5 +106,49 @@ void sched_shutdown(void)
                unregister_task(t);
 };
 
+char *get_task_list(void)
+{
+       struct task *t, *tmp;
+       char *msg = NULL;
+       list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) {
+               char *tmp_msg;
+               tmp_msg = make_message("%s%p\tpre\t%s\n", msg? msg : "", t, t->status);
+               free(msg);
+               msg = tmp_msg;
+       }
+       list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node) {
+               char *tmp_msg;
+//             if (t->pre_select)
+//                     continue;
+               tmp_msg = make_message("%s%p\tpost\t%s\n", msg? msg : "", t, t->status);
+               free(msg);
+               msg = tmp_msg;
+       }
+       //PARA_DEBUG_LOG("task list:\n%s", msg);
+       return msg;
+}
 
-//char *get_tast_list();
+int kill_task(char *id)
+{
+       struct task *t, *tmp;
+       char buf[20];
+       list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) {
+               sprintf(buf, "%p", t);
+               if (strcmp(id, buf))
+                       continue;
+               t->ret = -E_TASK_KILLED;
+               if (t->event_handler)
+                       t->event_handler(t);
+               return 1;
+       }
+       list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node) {
+               sprintf(buf, "%p", t);
+               if (strcmp(id, buf))
+                       continue;
+               t->ret = -E_TASK_KILLED;
+               if (t->event_handler)
+                       t->event_handler(t);
+               return 1;
+       }
+       return -E_NO_SUCH_TASK;
+}