synchronizing using completion function

来源:互联网 发布:碎屏 mac 壁纸高清 编辑:程序博客网 时间:2024/06/10 22:05

essential linux device dirver:

 

In the following example,  'my_release' is called when module is removed.

But before the module's unloaded, you have to make sure that 'my_thread'

has finished some very important task which will incur harmful effective to

our system if not properly handled. When 'my_thread' has finished the critical

task,  call 'complete_and_exit' to signal 'my_release' . In the 'my_releas'  side,

it can call 'wait_for_completion' to wait for 'my_thread' to exit. When 'my_release'

return from 'wait_for_completion' call,  the module can safely unloaded.

 

sample code: