X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=sched.c;h=879ab80820e56742815044d158f25aec965359db;hp=9db7c092e0209ac542283980773a9519a4f3b49a;hb=d46fe38dcada4108ed49a0e621376df0f7913fe3;hpb=37db6c718cbd9e350d46703c36dc6860477de476 diff --git a/sched.c b/sched.c index 9db7c092..879ab808 100644 --- a/sched.c +++ b/sched.c @@ -16,7 +16,10 @@ static void sched_preselect(struct sched *s) again: list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) { t->pre_select(s, t); - if (t->ret > 0 || !t->event_handler) +// PARA_INFO_LOG("%s \n", t->status); + if (t->ret > 0) + continue; + if (!t->event_handler) continue; t->event_handler(t); goto again; @@ -29,6 +32,7 @@ static void sched_post_select(struct sched *s) list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node) { t->post_select(s, t); +// PARA_INFO_LOG("%s: %d\n", t->status, t->ret); if (t->ret > 0 || !t->event_handler) continue; t->event_handler(t); @@ -102,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; +}