/*
- * Copyright (C) 2006-2014 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006 Andre Noll <maan@tuebingen.mpg.de>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
/** \file sched.c Paraslash's scheduling functions. */
#include <regex.h>
-#include <assert.h>
#include "para.h"
#include "ipc.h"
};
static struct timeval now_struct;
-struct timeval *now = &now_struct;
-
-static inline bool timeout_is_zero(struct sched *s)
-{
- struct timeval *tv = &s->select_timeout;
- return tv->tv_sec == 0 && tv->tv_usec == 0;
-}
+const struct timeval *now = &now_struct;
static void sched_preselect(struct sched *s)
{
static void unlink_and_free_task(struct task *t)
{
- PARA_INFO_LOG("freeing task %s\n", t->name);
+ PARA_INFO_LOG("freeing task %s (%s)\n", t->name, t->status < 0?
+ para_strerror(-t->status) :
+ (t->status == TS_DEAD? "[dead]" : "[running]"));
+
list_del(&t->node);
free(t->name);
free(t);
FD_ZERO(&s->wfds);
s->select_timeout = s->default_timeout;
s->max_fileno = -1;
- clock_get_realtime(now);
+ clock_get_realtime(&now_struct);
sched_preselect(s);
ret = s->select_function(s->max_fileno + 1, &s->rfds, &s->wfds,
&s->select_timeout);
FD_ZERO(&s->rfds);
FD_ZERO(&s->wfds);
}
- clock_get_realtime(now);
+ clock_get_realtime(&now_struct);
num_running_tasks = sched_post_select(s);
if (num_running_tasks == 0)
return 0;