문제

Scenario: Suppose if I am doing echo 1 > sysfs_entry - It will start doing some I/O operation until I do echo 0 > sysfs_entry. Here, I wanted to implement timer in sysfs_entry so that it should stop I/O operation after t seconds , even if I do not give echo 0 > sysfs_entry.

PS: I do not want to use busy wait methods.

Preferred: deferred/delayed work

Please somebody help me to resolve this scenario.

도움이 되었습니까?

해결책

You can use add_timer() and del_timer() API for this. Event queue might also work (depends on context). For more details, please read Chapter 7 «Time, Delays, and Deferred Work» of Linux Device Drivers (aka LDD) book that is available free of charge right here. The Timer API is described on page 198.

다른 팁

Add a timer with add_timer() in the write callback of the device driver and make sure to del_timer() or del_timer_sync() in the read callback.

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