문제

How can I make timeout = 1 second for wait_event_timeout function? Function : wait_event_timeout (wq,condition,timeout);

How can I make timeout = 1 second.

And if call function like that : wait_event_timeout(queue,flag!='n',30*HZ);

timeout =???

도움이 되었습니까?

해결책

The function wait_event_timeout takes its timeout value in jiffies. Use the constant HZ (number of timer ticks per second) to specify time in jiffies. The expression HZ is the equivalent of one second. The expression 30 * HZ is the equivalent of 30 seconds.

wait_event_timeout (wq,condition,HZ);

다른 팁

wait_event_timeout take timeout in jiffies. and HZ is a defined identifier in linux which means 1 second. So n * HZ means n seconds. Hope now you can convert jiffies time to real world time, like n millisecond = n*HZ/1000

just a remark: take into account that HZ differs from system to system. on most systems / kernels i know Hz is set to 100. so dividing it by 1000 to get milliseconds will always end up with value 0.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top