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

Linux Kernel Threads in Device Drivers

 Purpose
This examples shows how to create and stop a kernel thread.
The driver is implemented as a loadable module. In the init_module() routine five kernel threads are created. This kernel threads sleep one second, wake up, print a message and fall asleep again. On unload of the module (cleanup_module), the kernel threads are killed.
The example has been tested with Linux kernel 2.4.2 on Intel (uni processor only) and Alpha platform (COMPAQ Personal Workstation 500au (uni processor), DS20 and ES40 (SMP).
A version for the 2.2 kernel can be found here. Note: depending on the context of the creator of the threads the new threads may inherit properties from the parent you do not want to have. The new version avoids this by having keventd create the threads. The 2.2. kernel do not have a keventd, so this approach is not implementable there.
Functions in example
    * start_kthread: creates a new kernel thread. Can be called from any process context but not from interrupt. The functions blocks until the thread started.
    * stop_kthread: stop the thread. Can be called from any process context but the thread to be terminated. Cannot be called from interrupt context. The function blocks until the thread terminated.
    * init_kthread: sets the environment of the new threads. Is to be called out of the created thread.
    * exit_kthread: needs to be called by the thread to be terminated on exit
Creation of new Thread
A new thread is created with kernel_thread(). The thread inherits properties from its parents. To make sure that we do not get any weired properties, we let keventd create the new thread.
The new thread is created with start_kthread(). It uses a semaphore to block until the new thread is running. A down() blocks the start_kthread() routine until the corresponding up() call in init_kthread() is executed.
The new thread must call init_kthread() in order to let the creator continue.


相关文档:

Linux平台下安装Apache (by quqi99)

       Linux平台下安装Apache (by quqi99)
 
作者:张华 发表于:2009-11-19
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
 首先保证安装GCC与ZLIB
 安装ZLIB步骤:
1)./configure --prefix=/usr/zhang/zlib
2) make ......

[转]Linux操作系统文件系统基础知识详解

 一 、Linux文件结构
  文件结构是文件存放在磁盘等存贮设备上的组织方法。主要体现在对文件和目录的组织上。
  目录提供了管理文件的一个方便而有效的途径。
  Linux使用标准的目录结构,在安装的时候,安装程序就已经为用户创建了文件系统和完整而固定的目录组成形式,并指定了每个目录的作用和其中的文件 ......

很受欢迎的Linux笔记

 
linux目录架构
/   根目录
/bin    常用的命令
binary file 的目錄
/boot   存放系统启动时必须读取的档案,包括核心
(kernel) 在内
     /boot/grub/menu.lst   GRUB设置
     /boot/vmlinuz   内核
......

如何在Linux中添加新的系统调用

 系统调用是应用程序和操作系统内核之间的功能接口。其主要目的是使得用户
可以使用操作系统提供的有关设备管理、输入/输入系统、文件系统和进程控制、
通信以及存储管理等方面的功能,而不必了解系统程序的内部结构和有关硬件细
节,从而起到减轻用户负担和保护系统以及提高资源利用率的作用。
  Linux操作系统 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号