易截截图软件、单文件、免安装、纯绿色、仅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 汇编语言开发指南


developerWorks 中国
  >  
Linux
  >
Linux 汇编语言开发指南
文档选项
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td>< ......

Linux内核模块编程简介

主题: linux内核模块的程序结构--模块加载函数(必须),模块卸载函数(必须),模块许可证声明(必须),模块参数(可选),模块导出符号(可选),模块作者的等信息声明(可选)
一个linux内核模块主要由以下几个部分组成。
1、模块加载函数"用module_init()来指定"(必须)
   当通过insmod和modprobe命令加载内核模块时 ......

linux命令之grep


相信g r e p是U N I X和L I N U X中使用最广泛的命令之一。g r e p(全局正则表达式版本)允许对文本文件进行模式查找。如果找到匹配模式, g r e p打印包含模式的所有行。g r e p支持基本正则表达式,也支持其扩展集。g r e p有三种变形,即:
G r e p: 标准g r e p命令,本章大部分篇幅集中讨论此格式。
E g r e p: ......

实战Linux Bluetooth编程

文章来源:http://blog.chinaunix.net/u3/104073/showart_2081838.html
实战Linux Bluetooth编程(一) 协议栈概述
Sam一年前在Linux下写了一个类似Windows下BTW的库--BTX。现在需要添加新功能时发现很多知识点都忘记
了。所以决定在这次学习中,把一些bluez API记录下来。这几天又想,这样还不够,不如把Linux下的
Blu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号