Linux 内核WorkQueue阅读笔记
1. Workqueue
Workqueue的名字就和他的功能一样:需要处理的工作列表和工作的添加删除(貌似没有看到如何删除的)、以及工作的调度执行。
需要处理的工作列表通常都维护在内核对象workqueue_struct里面。系统里面可以有多个workqueue_struct。内核部分的工作添加到了工作队列keventd_wq。而fs/aio.c里面实现了自己的工作队列aio_wq。
workqueue_struct是双向循环链表。里面的单元是work_struct。
驱动接口:
create_workqueue:创建工作队列结构和内核处理线程。
schedule_work/schedule_delayed_work:调度执行一个具体的任务,执行的任务将会被挂入Linux系统提供的workqueue keventd_wq。请注意,调度执行并不等于立刻执行。而是指示worker_thread在下次处理工作队列的时候执行该工作;
queue_work/queue_delayed_work:调度执行一个指定workqueue中的任务。内核本身提供了一个工作队列keventd_wq。但是,系统里面也可以有其他的工作队列。所以就有了schedule_work和queue_work的区分。
1.1 schedule_work
从schedule_work的实现看,其和queue_work的实现区别并不大:
int schedule_work(struct work_struct *work)
{
return queue_work(keventd_wq, work);
}
int queue_work(struct workqueue_struct *wq, struct work_struct *work)
{
int ret;
ret = queue_work_on(get_cpu(), wq, work);
put_cpu();
return ret;
}
int
queue_work_on(int cpu, struct workqueue_struct *wq, struct work_struct *work)
{
int ret = 0;
相关文档:
用Linux下的LVS软件实现Linux集群
德英
发表于2010年03月15日 18:22
阅读( ......
所需文件hello.c, main.c, hello.h, Makefile,在同一个目录下
hello.c:
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}
main.c:
#include "stdio.h"
#include "hello.h"
// The second
int main()
{
hello("GCC");
printf("Haha Linux Ubuntu!\n");
......
Linux下锁用户与解锁问题 [原创 2010-02-03 21:44:35]
字号:大 中 小
一:登录失败次回超过限制
1)锁用户的设定
/etc/pam.d/下包含各种认证程序或服务的配置文件。编辑这些可限制认证失败次数,当失败次数超过指定值时用户会被锁住。
在此,以run level为3的时候,多次登录登录失败即锁用户为例:
......
包含3个文件夹,和一个文件Makefile
目录组织结构如下:
Makefile
inc/hello.h
main/main.c
src/hello.c
Makefile文件在外面,这样生成的.o和可执行文件都在外面,clean之后会很干净,结构清晰
文件内容如下:
Makefile(之所以用大写,因为make可以识别Makefile和makefile,用大写可以鲜明一些)::
# String declar ......
一.查看所有硬盘的uuid
ls -all /dev/disk/by-uuid
longseaker的实例
lrwxrwxrwx 1 root root 10 2009-09-19 08:17 05434a61-8a78-4ee5- a5db-6a49079b9e3d -> ../../sda5
lrwxrwxrwx 1 root root 10 2009-09-19 08:17 07D8-0104 -> ../../sda1
lrwxrwxrwx 1 root root 10 2009-09-19 08:17 18201249-998a-4bb1 ......