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.
内核空间和用户空间拷贝数据时
相关文档:
developerWorks 中国
>
Linux
>
Linux 汇编语言开发指南
文档选项
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td>< ......
网络配置:
VMware安装后会有几个默认网卡,分别是Vmnet0,Vmnet1和Vmnet8,常用HOST-ONLY,Bridge和NAT联网方式。本文介绍NAT方式。
Vmware设置:
在Vmware设置好Ubuntu的网络连接方式,选择NAT
IP地址可以通过vmware>edit>virtual networking settings 查看,如下图:
NAT设 ......
首先介绍下pthread_cond_t。 在Linux下称之为状态变量,与之相关的有下面几个API:
int pthread_cond_init (pthread_cond_t *COND,pthread_condattr_t *cond_ATTR);
int pthread_cond_signal (pthread_cond_t *COND);
int pthread_cond_broadcast (pthread_con ......
一、下载weblogic for linux ,版本很多,我下的是bin版本,这个版本的安装非常简单。我下载的是:[WebLogic.Platform.8.1.with.SP5.for.Linux英文版].platform815_linux32.bin 二 、想办法弄到虚拟机里的linux中。 我实在windows下面下载的,然后通过SSH上传到虚拟机里的,当然方法很多,在虚拟机里上网也是可以下载的。 ......
每个进程都有一个唯一的进程号。 每个进程都有一个父进程。 系统中的进程以树的形式组织,init进程(进程号为1)作为根。 进程0是调度进程,没有程序与之对应,是内核的一部分。 进程1是init进程,是在系统启动的阶段由内核启动的,对应/sbin/ini ......