zoukankan      html  css  js  c++  java
  • 中断下半部

    转自:http://blog.csdn.net/sudolee/article/details/6885634

    1>work_queue:<linux/workqueue.h> __3.0.4
    2>description:
    中断下半部,在内核线程的进程上下文中执行推后的工作.
    它是唯一能在进程上下文运行的中断下半部实现机制,也只有它才可以睡眠.
    3>创建推后的工作:

    1. DECLARE_WORK(const char *name, void (*func)(struct work_struct *work));  
    2. INIT_WORK(struct work_struct *work, void (*func)(struct work_struct *work));  
    3.   
    4. struct work_struct {  
    5.     atomic_long_t data;  
    6.     struct list_head entry;  
    7.     work_func_t func;                                                                                                                       
    8. #ifdef CONFIG_LOCKDEP  
    9.     struct lockdep_map lockdep_map;  
    10. #endif  
    11. };  
    12. typedef void (*work_func_t)(struct work_struct *work);  

    4>工作队列处理函数:

    1. /* 除了不能访问用户空间,它的确比软中断和tasklet方便不少.  
    2.  * 只有系统调用陷入内核,用户空间的内存才会被映射.  
    3.  */  
    4. void *func(struct work_struct *work);  

    5>调度(提交)工作:

    1. /* 把创建好的工作提交到缺省的worker线程(每个cpu一个,event/cpuno.).  
    2.  * 有时把这种工作队列也叫共享队列,因为很多驱动程序都将推后执行的工作提交到默认worker线程.  
    3.  */  
    4. int schedule_work(struct work_struct *work);  
    5. int schedule_delayed_work(struct delayed_work *work, unsigned long delay);  
    6. int schedule_on_each_cpu(work_func_t func);  

    6>刷新工作队列:

    1. /* 实际上,它只是等待(睡眠),直到缺省工作队列上的工作被执行.  
    2.  * complete()实现.  
    3.  */  
    4. void flush_scheduled_work(void);  
    5. /*等待指定的工作被执行*/  
    6. bool flush_work(struct work_struct *work);  
    7. bool flush_delayed_work(struct delayed_work *dwork);  

    7>取消工作:

    1. bool cancel_delayed_work(struct delayed_work *work);  
    2. bool cancel_work_sync(struct work_struct *work);  
    3. bool cancel_delayed_work_sync(struct delayed_work *dwork);  

    8>创建一个新的workqueue和对应的worker线程(每个cpu一个).

    1. /* 如果一个任务是处理器密集型和性能要求严格的 
    2.  * 那么可以选择创建自己的worker(工作者)线程 
    3.  * 当然,每个处理器一个. 
    4.  */  
    5. struct workqueue_struct *create_workqueue(const char *name);  
    6.   
    7. /* struct workqueue_struct *alloc_workqueue(const char *name, unsigned int flags, int max_active); 
    8.  * the maximum number of execution contexts per cpu, up to 512. 
    9.  */  

    9>调度(提交)队列

    1. int queue_work(struct workqueue_struct *wq, struct work_struct *work);  
    2. int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay);  

    10>刷新一个工作队列:

    1. /* 等待(睡眠),直到指定队列上的工作被执行. 
    2.  * 事实上除了指定工作队列,它和flush_scheduled_work()没有区别. 
    3.  */  
    4. void flush_workqueue(struct workqueue_struct *wq);  

    11>释放一个工作队列:

      1. void destroy_workqueue(struct workqueue_struct *wq);  
  • 相关阅读:
    接口测试基础一--HTTP请求
    python笔记8-python的异常处理
    web自动化测试中的八大定位方法,推荐使用xpath
    charles抓取https包
    Python 中WebElement 类中的部分操作
    selenium 启动浏览器后基本操作:后退、前进、刷新、关闭窗口、关闭会话
    fiddler抓包可以抓到电脑数据抓不到手机上的数据------防火墙问题
    Charles的安装与破解
    python+ selenium + webdriver的环境准备
    python——print函数
  • 原文地址:https://www.cnblogs.com/rzq232/p/2837067.html
Copyright © 2011-2022 走看看