X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=sched.c;h=879ab80820e56742815044d158f25aec965359db;hp=9356dd0c4d14be11fb1284eae7227a8489acf907;hb=d46fe38dcada4108ed49a0e621376df0f7913fe3;hpb=3d412f0e603b785291de86be66ff6472cd17246f diff --git a/sched.c b/sched.c index 9356dd0c..879ab808 100644 --- 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\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\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; +}