linux內核進程調度與控制.rar
linux內核進程調度與控制,linux內核進程調度與控制——源代碼分析與研究11萬字135頁摘要 本文對linux內核中進程調度和進程控制部分的源代碼分別進行了詳細的流程分析與代碼注釋,并對這兩部分的代碼實現進行了研究,闡述了它們的優(yōu)缺點。在進程調度部分,主要涉及了linux的調度算法及實現、時鐘中斷、定時器、linux內核機制以及系統(tǒng)調用nan...
該文檔為壓縮文件,包含的文件列表如下:


內容介紹
原文檔由會員 xiaowei 發(fā)布
Linux內核進程調度與控制
——源代碼分析與研究
11萬字 135頁
摘要
本文對Linux內核中進程調度和進程控制部分的源代碼分別進行了詳細的流程分析與代碼注釋,并對這兩部分的代碼實現進行了研究,闡述了它們的優(yōu)缺點。在進程調度部分,主要涉及了Linux的調度算法及實現、時鐘中斷、定時器、Linux內核機制以及系統(tǒng)調用nanosleep、pause。在進程控制部分,主要涉及了Linux系統(tǒng)調用的實現和進程的創(chuàng)建、裝入執(zhí)行、等待、消亡的過程。
關鍵詞:操作系統(tǒng) 進程 進程調度 中斷 定時器 運行隊列 系統(tǒng)調用 門 內核空間 用戶空間
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進程優(yōu)先級 ………………………………………………………14
3.1.6 Linux進程系統(tǒng)的特點 …………………………………………………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 系統(tǒng)定時器 ……………………………………………………………25
3.4系統(tǒng)調用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進程優(yōu)先級的代碼實現 …………………………………………30
3.5.3 Linux對CPU的充分利用 ………………………………………………30
第4章 Linux進程的控制 ………………………………………………31
4.1 進程的創(chuàng)建、執(zhí)行、消亡 ……………………………………………………31
4.1.1 系統(tǒng)調用的實現…………………………………………………………32
4.1.2 子進程的創(chuàng)建……………………………………………………………41
4.1.3 子進程的執(zhí)行……………………………………………………………46
4.1.4 父進程的等待……………………………………………………………48
4.1.5 子進程的消亡……………………………………………………………49
4.1.6 進程控制的全過程………………………………………………………51
4.2 對于Linux進程控制的研究總結 ……………………………………………52
4.2.1 Linux系統(tǒng)的內核保護與系統(tǒng)調用 ……………………………………52
4.2.2 Linux進程的創(chuàng)建、執(zhí)行、等待和消亡 ………………………………52
4.2.3 Linux進程的并發(fā)特性 …………………………………………………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 系統(tǒng)調用總控入口 ……………………………………………………………65
5.4 子進程的創(chuàng)建 …………………………………………………………………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 子進程的裝入和執(zhí)行 …………………………………………………………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 系統(tǒng)調用總控入口……………………………………………………………105
6.4 子進程的創(chuàng)建…………………………………………………………………106
6.5 子進程的裝入和執(zhí)行…………………………………………………………118
6.6 父進程的等待…………………………………………………………………123
6.7 子進程的消亡…………………………………………………………………126
結束語 …………………………………………………………………133
致謝 ……………………………………………………………………134
參考文獻 ………………………………………………………………135
翻譯譯文 ………………………………………………………………136
參考文獻
[1] 陳莉君編著. Linux操作系統(tǒng)內核分析.北京: 人民郵電出版社,2000
[2] 馮銳等譯. Linux內核源代碼分析.北京: 機械工業(yè)出版社,2000
[3] 李善平等編著.Linux操作系統(tǒng)及實驗教程.北京: 機械工業(yè)出版社,1999
——源代碼分析與研究
11萬字 135頁
摘要
本文對Linux內核中進程調度和進程控制部分的源代碼分別進行了詳細的流程分析與代碼注釋,并對這兩部分的代碼實現進行了研究,闡述了它們的優(yōu)缺點。在進程調度部分,主要涉及了Linux的調度算法及實現、時鐘中斷、定時器、Linux內核機制以及系統(tǒng)調用nanosleep、pause。在進程控制部分,主要涉及了Linux系統(tǒng)調用的實現和進程的創(chuàng)建、裝入執(zhí)行、等待、消亡的過程。
關鍵詞:操作系統(tǒng) 進程 進程調度 中斷 定時器 運行隊列 系統(tǒng)調用 門 內核空間 用戶空間
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進程優(yōu)先級 ………………………………………………………14
3.1.6 Linux進程系統(tǒng)的特點 …………………………………………………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 系統(tǒng)定時器 ……………………………………………………………25
3.4系統(tǒng)調用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進程優(yōu)先級的代碼實現 …………………………………………30
3.5.3 Linux對CPU的充分利用 ………………………………………………30
第4章 Linux進程的控制 ………………………………………………31
4.1 進程的創(chuàng)建、執(zhí)行、消亡 ……………………………………………………31
4.1.1 系統(tǒng)調用的實現…………………………………………………………32
4.1.2 子進程的創(chuàng)建……………………………………………………………41
4.1.3 子進程的執(zhí)行……………………………………………………………46
4.1.4 父進程的等待……………………………………………………………48
4.1.5 子進程的消亡……………………………………………………………49
4.1.6 進程控制的全過程………………………………………………………51
4.2 對于Linux進程控制的研究總結 ……………………………………………52
4.2.1 Linux系統(tǒng)的內核保護與系統(tǒng)調用 ……………………………………52
4.2.2 Linux進程的創(chuàng)建、執(zhí)行、等待和消亡 ………………………………52
4.2.3 Linux進程的并發(fā)特性 …………………………………………………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 系統(tǒng)調用總控入口 ……………………………………………………………65
5.4 子進程的創(chuàng)建 …………………………………………………………………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 子進程的裝入和執(zhí)行 …………………………………………………………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 系統(tǒng)調用總控入口……………………………………………………………105
6.4 子進程的創(chuàng)建…………………………………………………………………106
6.5 子進程的裝入和執(zhí)行…………………………………………………………118
6.6 父進程的等待…………………………………………………………………123
6.7 子進程的消亡…………………………………………………………………126
結束語 …………………………………………………………………133
致謝 ……………………………………………………………………134
參考文獻 ………………………………………………………………135
翻譯譯文 ………………………………………………………………136
參考文獻
[1] 陳莉君編著. Linux操作系統(tǒng)內核分析.北京: 人民郵電出版社,2000
[2] 馮銳等譯. Linux內核源代碼分析.北京: 機械工業(yè)出版社,2000
[3] 李善平等編著.Linux操作系統(tǒng)及實驗教程.北京: 機械工業(yè)出版社,1999