易截截图软件、单文件、免安装、纯绿色、仅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 Bluetooth编程(六) L2CAP编程实例

例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
 如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......

linux下gcc编译sin函数出错的问题

 
Q:
I
keep getting
errors due to library functions being undefined,
but I'm #including all
the right header files.
A:
In the general case of calling code in an
external library,
using #include
to pull in
the right header file(s) is only half
of the story; you also have to tell th ......

在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全攻略--yum服务器配置
Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora中的shell前端软件包管理器。基于rpm包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理 依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。
  软体包来源
可供Yum下载的软体包包括fedora ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号