سؤال

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