#include "error.h"
struct task {
- /** The task name supplied when the task was registered(). */
+ /** A copy of the task name supplied when the task was registered. */
char *name;
- /** Copied from the task_info struct during task_register(). */
- void (*pre_select)(struct sched *s, struct task *t);
- /** Copied from the task_info struct during task_register(). */
- int (*post_select)(struct sched *s, struct task *t);
+ /** Copied during task_register(). */
+ struct task_info info;
/** Whether this task is active (>=0) or in error state (<0). */
int status;
/** Position of the task in the task list of the scheduler. */
int notification;
/** True if task is in error state and exit status has been queried. */
bool dead;
- /** Usually a pointer to the struct containing this task. */
- void *context;
};
static struct timeval now_struct;
continue;
if (t->notification != 0)
sched_min_delay(s);
- if (t->pre_select)
- t->pre_select(s, t);
+ if (t->info.pre_select)
+ t->info.pre_select(s, t);
}
}
static inline void call_post_select(struct sched *s, struct task *t)
{
#ifndef SCHED_DEBUG
- t->status = t->post_select(s, t);
+ t->status = t->info.post_select(s, t);
#else
struct timeval t1, t2, diff;
unsigned long pst;
clock_get_realtime(&t1);
- t->status = t->post_select(s, t);
+ t->status = t->info.post_select(s, t);
clock_get_realtime(&t2);
tv_diff(&t1, &t2, &diff);
pst = tv2ms(&diff);
if (!s->task_list.next)
INIT_LIST_HEAD(&s->task_list);
+ t->info = *info;
t->name = para_strdup(info->name);
t->notification = 0;
t->status = 0;
t->dead = false;
- t->pre_select = info->pre_select;
- t->post_select = info->post_select;
- t->context = info->context;
list_add_tail(&t->node, &s->task_list);
return t;
}
*/
void *task_context(struct task *t)
{
- return t->context;
+ return t->info.context;
}
/**