ex.
#include linux/completion.h struct completion comp; void module_init{ //初始化my_completion, set comp.done=0 init_completion(&comp); } ssize_t complete_read (struct file *filp, char __user *buf, size_t count, loff_t *pos) { //等待所有的comp 都被complete. wait_for_completion(&comp); printk(KERN_DEBUG "awoken %i (%s)\n", current->pid, current->comm); return 0; /* EOF */ } ssize_t complete_write (struct file *filp, const char __user *buf, size_t count, loff_t *pos) { complete(&comp); return count; /* succeed, to avoid retrial */ }
沒有留言:
張貼留言