Home > other >  Kernel, how to implement a wait queue jam, strives for the process?
Kernel, how to implement a wait queue jam, strives for the process?

Time:10-02

Kernel, how to implement a wait queue jam, strives for the process?

CodePudding user response:

1. Define the wait_queue_head_t data structure
A) struct __wait_queue_head
2. The initialization wait_queue_head_t
A) init_waitqueue_head (q); Parameter q is a pointer
3. Where should block block
Wait_event (wq, condition); Switch up the process for uninterruptible sleep)
Wait_event_interruptible (wq, condition) will switch process for interruptible sleep)
Wait_event_timeout (wq, condition, the timeout) timeout automatically wake up
Wait_event_interruptible_timeout (wq, condition, the timeout)
The timeout is the variable of jiffies
Parameter is wq wait_queue_head_t variable name
Condition condition code to true, false when no traffic conditions so as to realize the blocking
4. Where need to wake up wake up
A) wake_up (x) realization awakens the condition is true when
B) wake_up_interruptible (x)
C) parameter x for the pointer
  • Related