1. Prototype
#define wait_ event_ interruptible_ timeout(wq_ head, condition, timeout) \
({ \
long __ ret = timeout; \
might_ sleep(); \
if (!___ wait_ cond_ timeout(condition)) \
__ ret = __ wait_ event_ interruptible_ timeout(wq_ head, \
condition, timeout); \
__ ret; \
})
2. Use scenarios
Sleep to meet the conditions or time out of sleep
3. It supports interruptible sleep, which means that it can send a signal to the sleep process, and the process will respond to the signal
4. Return value analysis
4.1 when the return value is greater than 0, it means that the remaining time (in Jiffy unit) is returned. If the condition is satisfied, that is, it has not timed out, and the condition has been reached, it will wake up
4.2 when the return value is 0, it means timeout and Automatic wake-up. At this time, handle the error according to the situation
Similar Posts:
- Analysis of Android sleep wake mechanism — wake_ lock
- Concurrent notes (4): Notes on the use of wait / notify / notifyAll method
- Java Thread wait, notify and notifyAll Example
- Idea suddenly reports an error for all package names
- The decode function solves the problem that Oracle reports an error “divisor is 0”
- Nginx Timeout Error: upstream timed out (110: Connection timed out) while reading response header from ups…
- Detailed explanation of PS AUX output parameter meaning
- Windows: SQL lab error “module object has no attribute sigalrm”
- Centos Systemctl Error getting authority: Error initializing authority: Error calling StartServ…
- Fault tolerance mechanism of failover, failfast, failback and failsafe