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

Linux Device Drivers阅读笔记

Linux Device Drivers, 3rd Edition
2.3.1. User Space and Kernel Space
内核空间和用户空间
Unix transfers execution from user space to kernel space whenever an application issues a system call or is suspended by a hardware interrupt. Kernel code executing a system call is working in the context of a process—it operates on behalf of the calling process and is able to access data in the process's address space. Code that handles interrupts, on the other hand, is asynchronous with respect to processes and is not related to any particular process.
这是很关键的段落:
Unix可以通过系统调用和硬件中断实现从用户空间到内核空间的切换。对于系统调用,内核代码运行于调用进程的上下文中,内核代码可以访问调用进程的数据。对于硬件中断,内核代码运行于中断上下文,独立于当前被打断的进程,所以此时不能访问被中断的当前进程空间的数据。
从用户空间切换到内核空间时要使用内核空间堆栈,linux内核空间堆栈<8k, 写内核程序要相当注意栈的使用。
当系统从内核空间返回或者从中断上下文中返回用户空间时,如果有重新调度需求,系统会进行重新调度,即用户抢占。
系统处于中断上下文或者进程持有自旋锁时不允许内核抢占。
内核抢占一般发生在,
    1 当系统在内核空间执行时,被某个中断打断,当从这个中断返回内核空间时。
    2 内核空间释放自旋锁时。
3.7. read and write
unsigned long copy_to_user(void _ _user *to,
const void *from,
unsigned long count);
unsigned long copy_from_user(void *to,
const void _ _user *from,
unsigned long count);
Although these functions behave like normal memcpy functions, a little extra care must be used when accessing user space from kernel code. The user pages being addressed might not be currently present in memory, and the virtual memory subsystem can put the process to sleep while the page is being transferred into place. This happens, for example, when the page must be retrieved from swap space.
内核空间和用户空间拷贝数据时


相关文档:

linux I2C驱动分析

I2C是Phillips开发的2线的串行总线协议。通常应用在嵌入式系统中让不同的组件通信,PC主板可以通过I2C来与不同的传感器通信。这些传感器通常报告风扇速度,处理器温度和整个硬件系统的信息,这个协议也可以用在RAM chips上,向操作系统提供DIMM的信息。
在2.0时I2C的kernel源码不在内核里的,2.4内核包括了一点对I2C的支持 ......

linux init六种模式简介


init是Linux系统里的根进程,是系统所有进程的祖先。它的主要作用是根据记录在/etc/inittab里的一个脚本(script)程序产生进程。这个文件通常用于控制用户的登录模式。Linux系统的有效登录模式有0~9共十种,不过沿用UNIX系统的至多6种的限制,一般只有1到6有效。
  init一般在系统启动时自动运行,也可以由root用户调 ......

linux命令之awk


Table of Contents
1. awk简介
2. awk命令格式和选项
2.1. awk的语法有两种形式
2.2. 命令选项
3. 模式和操作
3.1. 模式
3.2. 操作
4. awk的环境变量
5. awk运算符
6. 记录和域
6.1. 记录
6.2. 域
6.3. 域分隔符
7. gawk专用正则表达式元字符
8. POSIX字符集
9. 匹配操作符(~)
10. 比较表达式
11. 范围 ......

linux终端设备uart驱动分析

文章来源:http://blog.chinaunix.net/u3/94284/showart_1982227.html
一:前言
接着前面的终端控制台分析,接下来分析serial的驱动.在linux中,serial也对应着终端,通常被称为串口终端.在shell上,我们看到的/dev/ttyS*就是串口终端所对应的设备节点.
在分析具体的serial驱动之前.有必要先分析uart驱动架构.uart是Universal ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号