I have been trapped under the impression that `wait_queue` is always linked with task pending. However, this is totally wrong.
The major API of wait_queue is
1. initialization
DEFINE_WAIT_FUNC(name, function) or init_wait_queue_entry
2. add an entry to queue
void add_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
Variations:
poll_wait(...)
3. Helper functions do real wait for the schedule.
// CPU0 waker
wake_up(wq_head);
// CPU1 waiter
prepare_to_wait(&wq_head, &wait, state);
schedule();
if (@cond) {break;}
finish_wait(&wq_head, &wait);
// sleep until a condition gets true
wait_event(wq_head, condition)
P.S Glad to see the naming is moving to a less misleading situation. Basically the entry and head are named by their role, although the underlying struct is always list_head.
wait_queue_t -> wait_queue_entry_t
wait_queue_t::task_list -> wait_queue_entry_t::entry
wait_queue_head_t::task_list -> wait_queue_head_t::head
No comments:
Post a Comment