《深入理解Linux内核》阅读笔记 --- Chapter 3 Processes
Process Switching
1、The set of data that must be loaded into the registers before the process resumes its execution on the CPU is called the hardware context.In Linux, a part of the hardware context of a process is stored in the process descriptor, while the remaining part is saved in the Kernel Mode stack.
2、Process switching occurs only in Kernel Mode.The contents of all registers used by a process in User Mode have already been saved on the Kernel Mode stack before performing process switching.This includes the contents of the ss and esp pair that specifies the User Mode stack pointer address.
3、The 80x86 architecture includes a specific segment type called the Task State Segment(TSS), to store hardware contexts.When an 80x86 CPU switches from User Mode to Kernel Mode, it fetches the address of the Kernel Mode stack from the TSS.
4、Each process descriptor includes a field called thread of type thread_struct, in which the kernel saves the hardware context whenever the process is being switched out.This data structure includes fields for most of the CPU registers, except the general-purpose registers such as eax, ebx, etc, which are stored in the Kernel Mode stack.
Processes,Lightweight Processes, and Threads
Linux uses lightweight processes to offer better support for multithreaded applications.Basically, two lightweight processes may share some resources, like the address space, the open files, and so on.Whenever one of them modifies a shared resource, the other immediately sees the change.
A straightforward way to implement multithreaded applications is to associate a lightweight process with each thread.
In Linux a thread group is basically a set of lightweight processes that implement a multithreaded application and act as a whole with regards to some system calls such as getpid(), kill(), and _exit().
Unix programmers expect threads in the same group to have a common PID.To comply with this standard, Linux makes use of thread groups.The identifier shared by the threads is the PID of the thread group leader, that is, the PID of the first lightweight process in the group;it is stored in the tgid field of the process descriptors.The getpid() system call returns the value of tgid relative to the current process instead of the value of pid, so all the threads of a multithreaded application share the same identifier.Most processes belong to a thread group consisting of a single member; as thread group leaders, they have the tgid field equal to the pid field, thus the getpid() system call works as usual for this kind of process.
《深入理解Linux内核》阅读笔记 --- Chapter 3 Processes的更多相关文章
- 深入理解Linux内核 学习笔记(1)
1.用户和用户组 每个用户是一个或多个用户组的一名成员,组由唯一的用户组标识符(user group ID)标识.每个文件的相关权限也恰好与一个组相对应. root为超级用户, 2.模块 为了达到微内 ...
- 深入理解Linux内核 学习笔记(5)
第五章 定时测量 内核必须显式地与三种时钟打交道:实时时钟(Real Time Clock, RTC).时间标记计数器(Time Stamp Counter, TSC)及可编程间隔定时器( Prog ...
- 深入理解Linux内核 学习笔记(4)
第四章 中断和异常 中断通常被分为同步中断和异步中断,同步中断是当指令执行时由CPU控制单元产生的,之所以称为同步,是因为只有在一条指令终止执行后CPU才会发出中断异步中断是由其他硬件设备依照CPU时 ...
- 深入理解Linux内核 学习笔记(3)
第三章 进程 可以看到很多熟悉的结构体 进程状态: 可运行状态(TASK_ RUNNING) 进程要么在CPU上执行,要么准备执行. 可巾断的等待状态(TASK_ INTERRUPTIBLE) 进程被 ...
- 深入理解Linux内核 学习笔记(2)
第二章 :内存寻址 略.基本同计算机组成原理中的讲述 内核代码和数据结构会存储在一个保留的页框中. 常规Linux安装在RAM物理地址0x00100000开始的地方.因为:页框0是由BIOS使用,存放 ...
- 深入理解Linux内核 学习笔记(8)
第八章 系统调用 API定义了一个给定的服务:系统调用是通过软中断向内核发出一个明确的请求. API可能不调用系统调用,也可能调用多个系统调用. Linux系统调用必须通过执行int 0x80,系统调 ...
- 《深入理解Linux内核》 读书笔记
深入理解Linux内核 读书笔记 一.概论 操作系统基本概念 多用户系统 允许多个用户登录系统,不同用户之间的有私有的空间 用户和组 每个用于属于一个组,组的权限和其他人的权限,和拥有者的权限不一样. ...
- 读书笔记之Linux系统编程与深入理解Linux内核
前言 本人再看深入理解Linux内核的时候发现比较难懂,看了Linux系统编程一说后,觉得Linux系统编程还是简单易懂些,并且两本书都是讲Linux比较底层的东西,只不过侧重点不同,本文就以Linu ...
- 【读书笔记::深入理解linux内核】内存寻址【转】
转自:http://www.cnblogs.com/likeyiyy/p/3837272.html 我对linux高端内存的错误理解都是从这篇文章得来的,这篇文章里讲的 物理地址 = 逻辑地址 – 0 ...
随机推荐
- Python 函数进阶(filter/map/json/zip)
一.函数即变量 def say(name): print(name)ybq = say #可以被赋值给其他变量ybq('Amily') #调用函数 函数名:say 函数体:第1-2行 返回值:retu ...
- hdu1025 最大上升字串
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65 ...
- MySQL5.7的配置文件
5.7 /etc/mysql/mysql.conf.d/mysqld.cnf 5.6 /etc/my.cnf 或 /etc/mysql/my.cnf
- httpClient使用中报错org.apache.commons.httpclient.HttpMethodBase - Going to buffer response body of large or unknown size.
在使用HttpClient发送请求,使用httpMethod.getResponseBodyAsString();时当返回值过大时会报错: org.apache.commons.httpclient. ...
- linux查看硬盘空间 文件大小
du,disk usage,是通过搜索文件来计算每个文件的大小然后累加,du能看到的文件只是一些当前存在的,没有被删除的.他计算的大小就是当前他认为存在的所有文件大小的累加和 df,disk free ...
- 当input被选中时候获取改input的多个属性值
<input name="selectTicket" class="selectTic" data-property="${couponDeta ...
- jqgrid的排序问题
今天是本人解决的一个小bug 所以写的粗略些. 问题是这样的ORDER BY a.$sidx $sord 当时本人排序时候没用jqgrid的默认排序(可能今天这个大家看不懂,很抱歉啊各位,今天主要 ...
- 用n(0)次求一个数组里面最大子数组的和(数组可以输入负数)
今天老师布置了题目上的任务,可谓是杀死人脑细胞不偿命呐... 在课上叽叽咕咕的讨论了一节课也没有答案,只得出几个备选方案,一个是通过枚举法将数组里面的子数组和一个个列出来然后在进行比较,可想而知(n2 ...
- MathType可以编辑物理公式吗
很多的物理专业的人都在为编辑物理公式头疼,其实要写出这些公式并不难,要写出这些物理公式,那你就需要一个MathType公式编辑器!这是一款专业的公式编辑器,不管多复杂的公式或方程,都可以用它编辑出来, ...
- Chem 3D中怎么创建立体模型
ChemDraw作为一款很受大家欢迎的化学绘图软件,其在绘制平面化学方面的功能已经非常的强大了,其实它也可以绘制3D图形.Chem 3D就是绘制3D图形的重要组件.而且为了满足不同的用户绘图的需求,可 ...