- 论坛徽章:
- 0
|
本帖最后由 1ming0 于 2012-02-29 14:13 编辑
我写个模块 想定时的去执行事件, 但是dequeue事件是打开管道,不知道什么原因总是BUG: scheduling while atomic: xxxxxxxx; 这样的崩溃信息。
加了NONBLOCK还是不行。- int dequeue(void)
- {
- while(queue_head.next != NULL)
- {
- struct queue_nod *tmp;
- mm_segment_t old_fs;
- printk("dequeue 1111\n");
- struct file *fp = filp_open("/fifo_dir", O_WRONLY|O_NONBLOCK, 0644);
- if(IS_ERR(fp))
- {
- printk("open file failed\n");
- return -1;
- }
- old_fs = get_fs();
- set_fs(get_ds());
- printk("dequeue 2222\n");
- if(vfs_write(fp, queue_head.next->data, 100,&fp->f_pos) > 0)
- {
- printk("dequeue 3333\n");
- tmp = queue_head.next;
- queue_head.next = queue_head.next->next;
- queue_head.next->before = &queue_head;
- kfree(tmp);
- }
- filp_close(fp,NULL);
- set_fs(old_fs);
- }
- return 0;
- }
- struct timer_list mytimer;
- static void myfunc(unsigned long data)
- {
- printk("%s/n", (char *)data);
- dequeue();
- mod_timer(&mytimer, jiffies + 2*HZ);
- }
- static int __init mytimer_init(void)
- {
- setup_timer(&mytimer, myfunc, (unsigned long)"Hello, world!");
- mytimer.expires = jiffies + HZ;
- add_timer(&mytimer);
- return 0;
- }
- static void __exit mytimer_exit(void)
- {
- del_timer(&mytimer);
- }
- static int __init this_init(void)
- {
- mytimer_init();
- return ret;
- }
- static void __exit this_fini(void)
- {
- mytimer_exit();
- }
- module_init(this_init);
- module_exit(this_fini);
复制代码 |
|