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

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 GCC make文件的写法1

所需文件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驱动之makefile详解

# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
    obj-m := hello.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
    ......

linux 自动挂载硬盘

一.查看所有硬盘的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 ......

Ubuntu8.04下编译linux内核

今天看到师兄工位上有本Linux Kernel In a Nutshell,还是全英的影印版,所以就借过来看看,发现现在看英文的书渐渐适应了,还是比较容易的,书中开始介绍如何编译Linux内核,Linux内核大三的时候也学过编译过,但是当时编译比较简单,这次决定再重头到尾好好编译一下,首先下载linux kernel,再用secureCRT上传到Ubuntu 8. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号