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;
相关文档:
文件在两个文件夹:
inc/hello.h
main/hello.c, main.c, Makefile
文件内容:
hello.h
void hello(char name[]);
hello.c
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}
main.c
#include <stdio.h>
#include "../inc/hello.h"
// The second
int main( ......
包含3个文件夹
目录组织结构如下:
inc/hello.h
main/main.c, Makefile
src/hello.c
文件内容如下:
hello.h:
void hello(char name[]);
main.c:
#include <stdio.h>
#include "../inc/hello.h"
// The second hello.h should in ""
int main()
{
hello("GCC");
printf("Haha Linux Ub ......
Linux
/ Linux文件系统的入口,也是处于最高一级的目录;
/bin 基础系统所需要的那些命令位于此目录,也是最小系统所需要的命令;比如 ls、cp、mkdir等命令;功能和/usr/bin类似,这个目录中的文件都是可执行的,普通用户都可以使用的命令。做为基础系统所需要的最基础的命令就是放在这里。
/boot Linux的内核及引导系 ......
复制以下内容,保存为 py 后缀的文件,拷贝到wallpaper文件夹,进入文件夹,以python运行,选取xml为壁纸
#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
# Ubuntu 9.10 dynamic wallpaper maker_Can be used in all the distributions of linux
#
# Auto generate a configuration file which you can use ......