From: Andre Noll Date: Thu, 21 Jul 2011 17:39:03 +0000 (+0200) Subject: sched: Kill unnecessary check in sched_pre_select(). X-Git-Tag: v0.4.8~11^2~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=7544e25415144894b58e48ab17de21a693ea00c7;ds=sidebyside sched: Kill unnecessary check in sched_pre_select(). The only two callers of sched_shutdown() call this function from post_select context, so we may safely remove the check whether the pre_select list is empty. Add a comment to sched_shutdown() which mentions that this function must be called from post_select. --- diff --git a/sched.c b/sched.c index 8648811d..7b5ca63d 100644 --- a/sched.c +++ b/sched.c @@ -52,18 +52,8 @@ static void sched_preselect(struct sched *s) list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) { if (t->pre_select) t->pre_select(s, t); -// PARA_INFO_LOG("%s \n", t->status); - if (t->error >= 0) - continue; - /* - * We have to check whether the list is empty because the call - * to ->pre_select() might have called sched_shutdown(). In - * this case t has been unregistered already, so we must not - * unregister it again. - */ - if (list_empty(&pre_select_list)) - return; - unregister_task(t); + if (t->error < 0) + unregister_task(t); } } @@ -97,7 +87,12 @@ static void sched_post_select(struct sched *s) // PARA_INFO_LOG("%s: %d\n", t->status, t->ret); if (t->error >= 0) continue; - /* nec., see sched_preselect() */ + /* + * We have to check whether the list is empty because the call + * to ->post_select() might have called sched_shutdown(). In + * this case t has been unregistered already, so we must not + * unregister it again. + */ if (list_empty(&post_select_list)) return; unregister_task(t); @@ -197,7 +192,8 @@ void register_task(struct task *t) * Unregister all tasks. * * This will cause \a schedule() to return immediately because both the - * \a pre_select_list and the \a post_select_list are empty. + * \a pre_select_list and the \a post_select_list are empty. This function + * must be called from the post_select (rather than the pre_select) method. */ void sched_shutdown(void) {