易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux中的工作队列(work queue)

工作队列(work queue)是Linux kernel中将工作推后执行的一种机制。这种机制和BH(bottom half)或Tasklets不同之处在于工作队列是把推后的工作交由一个内核线程去执行,因此工作队列的优势就在于它允许重新调度甚至睡眠。
linux 2.6.20以后,工作队列机制和之前的版本有一点不同,在网上找了一点资料,也相应的看了一些code,现在自己总结一下:
原文参考:
http://wiki.365linux.cn/index.php?doc-view-39
http://blog.csdn.net/lanmanck/archive/2009/11/05/4770030.aspx
work queue的头文件: /kernel/include/linux/workqueue.h
work queue的数据结构:
struct work_struct {
    atomic_long_t data;
#define WORK_STRUCT_PENDING 0                  /* T if work item pending execution */
#define WORK_STRUCT_FLAG_MASK                 (3UL)
#define WORK_STRUCT_WQ_DATA_MASK         (~WORK_STRUCT_FLAG_MASK)
    struct list_head entry;
    work_func_t func;
#ifdef CONFIG_LOCKDEP
    struct lockdep_map lockdep_map;
#endif
};
其中 work_func_t 的定义如下:
typedef void (*work_func_t)(struct work_struct *work);
work queue 主要的 API:
INIT_WORK(struct work_struct *work, work_func_t func)
INIT_DELAYED_WORK(struct delayed_work *work, work_func_t func)
int schedule_work(struct work_struct *work)
void flush_scheduled_work(void)
int schedule_delayed_work(struct delayed_work *work, unsigned long delay)
int cancel_delayed_work(struct delayed_work *work)
struct workqueue_struct *create_workqueue(const char *name)
int queue_work(struct workqueue_struct *wq, struct work_struct *work)
int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay)
void flush_workqueue(struct workqueue_struct *wq)
void destroy_workqueue(struct workqueue_struct *wq)
work queue 的使用实例:
struct my_work_t {
    ch


相关文档:

在linux字符模式下使用proxy

export http_proxy=http://username:password@server:80
这个只能在当前窗口下使用,关闭窗口命令自动失效。
 
Wget下载是用proxy:
在当前用户目录下建立一个.wgetrc文件,内容:
http-proxy = 111.111.111.111:8080
ftp-proxy = 111.111.111.111:8080
分别表示http的代理服务器和ftp的代理服务器。如果代理服 ......

在linux中安装中文字库

                                                   ......

linux常用命令大全

linux常用命令大全
Linux 入门常用命令
1.      Linux进入与退出系统
1.1进入Linux系统:
必须要输入用户的账号,在系统安装过程中可以创建以下两种帐号:
  1.root--超级用户帐号(系统管理员),使用这个帐号可以在系统中做任何事情。
  2.普通用户--这个帐号供普通用户使用,可以 ......

VM+linux网络设置


VM-Linux-如何配置网络(2009-07-26 03:01:29)
标签:vm 配置网络 linux it 
分类:IT
配置虚拟机的网络
  光有虚拟机是不够的,我们需要使用虚拟机和真实主机以及其他的虚拟机进行通讯。通讯分两个部分,一个是局域网内的,另一个是连接到公网的。这一部分是重点,三种不同模式的用途就要揭晓 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号