#define TASK_WOKEN_RES 0x2000 /* woken up because of available resource */
#define TASK_WOKEN_OTHER 0x4000 /* woken up for an unspecified reason */
+#define TASK_F_TASKLET 0x8000 /* nature of this task: 0=task 1=tasklet */
+
/* use this to check a task state or to clean it up before queueing */
#define TASK_WOKEN_ANY (TASK_WOKEN_OTHER|TASK_WOKEN_INIT|TASK_WOKEN_TIMER| \
TASK_WOKEN_IO|TASK_WOKEN_SIGNAL|TASK_WOKEN_MSG| \
#define TASK_COMMON \
struct { \
unsigned short state; /* task state : bitfield of TASK_ */ \
- short nice; /* task prio from -1024 to +1024, or -32768 for tasklets */ \
+ short nice; /* task prio from -1024 to +1024 */ \
unsigned int calls; /* number of times process was called */ \
struct task *(*process)(struct task *t, void *ctx, unsigned short state); /* the function which processes the task */ \
void *context; /* the task's context */ \
#define TIMER_LOOK_BACK (1U << 31)
/* tasklets are recognized with nice==-32768 */
-#define TASK_IS_TASKLET(t) ((t)->nice == -32768)
+#define TASK_IS_TASKLET(t) ((t)->state & TASK_F_TASKLET)
/* a few exported variables */
return t;
}
-/* Initialize a new tasklet. It's identified as a tasklet by ->nice=-32768. It
- * is expected to run on the calling thread by default, it's up to the caller
- * to change ->tid if it wants to own it.
+/* Initialize a new tasklet. It's identified as a tasklet by its flags
+ * TASK_F_TASKLET. It is expected to run on the calling thread by default,
+ * it's up to the caller to change ->tid if it wants to own it.
*/
static inline void tasklet_init(struct tasklet *t)
{
- t->nice = -32768;
+ t->nice = 0;
t->calls = 0;
- t->state = 0;
+ t->state = TASK_F_TASKLET;
t->process = NULL;
t->tid = -1;
#ifdef DEBUG_TASK
budgets[queue]--;
t = (struct task *)LIST_ELEM(tl_queues[queue].n, struct tasklet *, list);
- state = t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING|TASK_HEAVY|TASK_KILLED);
+ state = t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING|TASK_HEAVY|TASK_F_TASKLET|TASK_KILLED);
ti->flags &= ~TI_FL_STUCK; // this thread is still running
activity[tid].ctxsw++;
_HA_ATOMIC_SUB(&sched->rq_total, 1);
- if (TASK_IS_TASKLET(t)) {
+ if (state & TASK_F_TASKLET) {
uint64_t before = 0;
LIST_DEL_INIT(&((struct tasklet *)t)->list);