Solve Linux system driver synchronization and mutual exclusion

  

Event waiting queue is generally used for asynchronous communication of Linux driver. It can also be called application device usage right waiting queue. When multiple processes are going to operate a device, the event queue is generally used at this time.

1, can not interrupt sleep:

wait_event(queue, condition)

wait_event_interruptible(queue, condition)

Two functions only become in condition True can wake up, otherwise it will sleep all the time, that is, calling wake_up() will not wake up. Zzzzzzzzzzzzz

2, interruptible sleep

wait_event_timeout(queue, condition, timeout)

wait_event_interruptible_timeout(queue, condition, timeout)

Whether the condition becomes true or wake_up_interruptible() is called can be awakened.

3, wake up function:

void wake_up(wait_queue_head_t *queue); //wake up all

void wake_up_interruptible(wait_queue_head_t *queue); //wake up interruptible

Copyright © Windows knowledge All Rights Reserved