linux0.11内核进程0pause前是怎么实现进程调度的,Linux内核进程调度与控制

内容介绍

原文档由会员 xiaowei 发布

Linux内核进程调度与控制

——源代码分析与研究

11万字 135页

摘要

本文对Linux内核中进程调度和进程控制部分的源代码分别进行了详细的流程分析与代码注释,并对这两部分的代码实现进行了研究,阐述了它们的优缺点。在进程调度部分,主要涉及了Linux的调度算法及实现、时钟中断、定时器、Linux内核机制以及系统调用nanosleep、pause。在进程控制部分,主要涉及了Linux系统调用的实现和进程的创建、装入执行、等待、消亡的过程。

关键词:操作系统 进程 进程调度 中断 定时器 运行队列 系统调用 门 内核空间 用户空间

ABSTRACT

In this article ,we have written the program flow and comment of the code that about The Process Scheduling and Control of Linux Kernel。We also make a research on implementation of the code and indicate the strongpoint and shortcoming of it. In Process Scheduling,the things we have done include the algorithms and implementation of process scheduling,time interrupt,timer,bottom half,nanosleep and pause. In Process Control, the things what we have done include the implementation of System Call and the course of the process creating,exec,wait and exit.

Key Words: Oprerating system Process Process sceduling Interrupt Timer Run-queue System call Gate Kernel space User space

目录

第1章 引言 ………………………………………………………………1

第2章 Linux内核的整体结构……………………………………………2

第3章 Linux进程调度……………………………………………………4

3.1 相关概念简述……………………………………………………………………4

3.1.1 Linux进程的四个要素……………………………………………………4

3.1.2 task_struct结构描述……………………………………………………4

3.1.3 调度与时间片……………………………………………………………14

3.1.4 实时进程与非实时进程…………………………………………………14

3.1.5 Linux进程优先级 ………………………………………………………14

3.1.6 Linux进程系统的特点 …………………………………………………15

3.2 进程的调度 ……………………………………………………………………17

3.2.1 Linux进程调度的策略 …………………………………………………18

3.2.2 Linux进程的调度算法 …………………………………………………18

3.2.3 Linux进程的调度时机 …………………………………………………18

3.2.4 Linux进程的队列 ………………………………………………………18

3.2.5 Linux进程调度全过程 …………………………………………………20

3.2.6 schedule( )及其调用函数 ……………………………………………22

3.3 时钟中断 ………………………………………………………………………23

3.3.1 时钟………………………………………………………………………23

3.3.2 实时时钟中断……………………………………………………………23

3.3.3 bottom half处理机制 …………………………………………………24

3.3.4 系统定时器 ……………………………………………………………25

3.4系统调用nanosleep( )和pause( ) …………………………………………27

3.4.1 nanosleep( )及部分子程序……………………………………………28

3.4.2 sys_pause( )……………………………………………………………29

3.5对于Linux进程调度的研究总结 ……………………………………………30

3.5.1 Linux对调度算法的应用 ………………………………………………30

3.5.2 Linux进程优先级的代码实现 …………………………………………30

3.5.3 Linux对CPU的充分利用 ………………………………………………30

第4章 Linux进程的控制 ………………………………………………31

4.1 进程的创建、执行、消亡 ……………………………………………………31

4.1.1 系统调用的实现…………………………………………………………32

4.1.2 子进程的创建……………………………………………………………41

4.1.3 子进程的执行……………………………………………………………46

4.1.4 父进程的等待……………………………………………………………48

4.1.5 子进程的消亡……………………………………………………………49

4.1.6 进程控制的全过程………………………………………………………51

4.2 对于Linux进程控制的研究总结 ……………………………………………52

4.2.1 Linux系统的内核保护与系统调用 ……………………………………52

4.2.2 Linux进程的创建、执行、等待和消亡 ………………………………52

4.2.3 Linux进程的并发特性 …………………………………………………52

第5章 Linux内核源码模块功能 ………………………………………53

5.1 进程调度 ………………………………………………………………………53

5.1.1 schedule( )………………………………………………………………53

5.1.2 goodness( )………………………………………………………………54

5.1.3 switch_mm( ) ……………………………………………………………56

5.1.4 add_to_runqueue( ) ……………………………………………………56

5.1.5 del_from_runqueue( ) …………………………………………………57

5.1.6 move_last_runqueue( )…………………………………………………57

5.1.7 move_first_runqueue( ) ………………………………………………57

5.2 nanosleep,pause及时钟函数 ………………………………………………58

5.2.1 sys_nanosleep ( )………………………………………………………58

5.2.2 schedule_timeout ( ) …………………………………………………58

5.2.3 internal_add_timer( ) ………………………………………………59

5.2.4 run_timer_list( ) ……………………………………………………61

5.2.5 sys_pause ( )……………………………………………………………61

5.2.6 do_timer_interrupt( ) ………………………………………………62

5.2.7 do_timer ( )……………………………………………………………63

5.2.8 do_bottom_half( ) ……………………………………………………63

5.2.9 timer_bh ( )……………………………………………………………65

5.3 系统调用总控入口 ……………………………………………………………65

5.4 子进程的创建 …………………………………………………………………66

5.4.1 sys_fork ( ) ……………………………………………………………66

5.4.2 sys_clone ( )……………………………………………………………66

5.4.3 sys_vfork ( )……………………………………………………………67

5.4.4 do_fork ( )………………………………………………………………67

5.4.5 get_pid ( )………………………………………………………………70

5.4.6 copy_fs ( )………………………………………………………………70

5.4.7 copy_mm ( )………………………………………………………………72

5.4.8 copy_files ( ) …………………………………………………………73

5.4.9 copy_sighand ( ) ………………………………………………………73

5.4.10 copy_thread ( ) ………………………………………………………77

5.5 子进程的装入和执行 …………………………………………………………78

5.5.1 sys_execve ( ) …………………………………………………………78

5.5.2 getname ( ) ……………………………………………………………79

5.5.3 do_execve ( ) …………………………………………………………79

5.5.4 search_binary_handler ( ) …………………………………………81

5.6 父进程的等待 …………………………………………………………………82

5.6.1 sys_wait4 ( ) …………………………………………………………82

5.6.1 release_task ( ) ………………………………………………………83

5.7 子进程的消亡 …………………………………………………………………86

5.7.1 sys_exit ( ) …………………………………………………………86

5.7.2 do_exit ( )………………………………………………………………86

5.7.3 __exit_mm ( )……………………………………………………………87

5.7.4 __exit_files ( ) ………………………………………………………88

5.7.5 __exit_fs ( )……………………………………………………………89

5.7.6 __exit_notify ( ) ……………………………………………………89

5.7.7 __exit_sighand ( ) …………………………………………………90

第6章 Linux内核源代码分析 …………………………………………92

6.1 进程调度 ………………………………………………………………………92

6.2 nanosleep,pause及时钟函数 ………………………………………………99

6.3 系统调用总控入口……………………………………………………………105

6.4 子进程的创建…………………………………………………………………106

6.5 子进程的装入和执行…………………………………………………………118

6.6 父进程的等待…………………………………………………………………123

6.7 子进程的消亡…………………………………………………………………126

结束语 …………………………………………………………………133

致谢 ……………………………………………………………………134

参考文献 ………………………………………………………………135

翻译译文 ………………………………………………………………136

参考文献

[1] 陈莉君编著. Linux操作系统内核分析.北京: 人民邮电出版社,2000

[2] 冯锐等译. Linux内核源代码分析.北京: 机械工业出版社,2000

[3] 李善平等编著.Linux操作系统及实验教程.北京: 机械工业出版社,1999

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值