Skip to contentSkip to conversation

Is it possible to wait on multiple wait_queues?

DISCUSSION Stuart MacDonald 1 participant 1 message Aug 23, 2004

lore
Share & tools
lore
#0 lore raw

Is there anything wrong with the code below (which has been modified from the __wait_event_interruptible macro)? Assuming of course that (condition) checks for both conditions.

..Stu

#define __wait_event2_interruptible(wq1, wq2, condition, ret) \

do {									\
	wait_queue_t __wait1, __wait2;					\
	init_waitqueue_entry(&__wait1, current);			\
	init_waitqueue_entry(&__wait2, current);			\
									\
	add_wait_queue(&wq1, &__wait1);					\
	add_wait_queue(&wq2, &__wait2);					\
	for (;;) {							\
		set_current_state(TASK_INTERRUPTIBLE);			\
		if (condition)						\
			break;						\
		if (!signal_pending(current)) {				\
			schedule();					\
			continue;					\
		}							\
		ret = -ERESTARTSYS;					\
		break;							\
	}								\
	current->state = TASK_RUNNING;					\
	remove_wait_queue(&wq1, &__wait1);				\
	remove_wait_queue(&wq2, &__wait2);				\
} while (0)