__decl_thread(extern HA_RWLOCK_T wq_lock); /* RW lock related to the wait queue */
void task_kill(struct task *t);
-void __task_wakeup(struct task *t, struct eb_root *);
+void __task_wakeup(struct task *t);
void __task_queue(struct task *task, struct eb_root *wq);
struct work_list *work_list_create(int nbthread,
{
unsigned short state;
-#ifdef USE_THREAD
- struct eb_root *root;
-
- if (t->thread_mask == tid_bit || global.nbthread == 1)
- root = &sched->rqueue;
- else
- root = &rqueue;
-#else
- struct eb_root *root = &sched->rqueue;
-#endif
-
state = _HA_ATOMIC_OR(&t->state, f);
while (!(state & (TASK_RUNNING | TASK_QUEUED))) {
if (_HA_ATOMIC_CAS(&t->state, &state, state | TASK_QUEUED)) {
t->debug.caller_file[t->debug.caller_idx] = file;
t->debug.caller_line[t->debug.caller_idx] = line;
#endif
- __task_wakeup(t, root);
+ __task_wakeup(t);
break;
}
}
* The task must not already be in the run queue. If unsure, use the safer
* task_wakeup() function.
*/
-void __task_wakeup(struct task *t, struct eb_root *root)
+void __task_wakeup(struct task *t)
{
+ struct eb_root *root = &sched->rqueue;
+
#ifdef USE_THREAD
- if (root == &rqueue) {
+ if (t->thread_mask != tid_bit && global.nbthread != 1) {
+ root = &rqueue;
+
HA_SPIN_LOCK(TASK_RQ_LOCK, &rq_lock);
- }
- if (root == &rqueue) {
global_tasks_mask |= t->thread_mask;
grq_total++;
t->rq.key = ++global_rqueue_ticks;
t->call_date = now_mono_time();
eb32sc_insert(root, &t->rq, t->thread_mask);
+
#ifdef USE_THREAD
if (root == &rqueue) {
_HA_ATOMIC_OR(&t->state, TASK_GLOBAL);