




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
操作系統(tǒng)Eva課lua程tio設(shè)n
on計(jì)ly.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.文華學(xué)院信息學(xué)部李勝利12012級(jí)操作系統(tǒng)Eva課lua程tio設(shè)n
o計(jì)n計(jì)ly.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.2內(nèi)容簡(jiǎn)介設(shè)計(jì)目的設(shè)計(jì)內(nèi)容實(shí)施方法及要求時(shí)間安排輔導(dǎo)Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.3設(shè)計(jì)目的·掌握Linux操作系統(tǒng)的使用方法·了解Linux系統(tǒng)Ev內(nèi)al核ua代ti碼on結(jié)on構(gòu)ly.ated
with
Aspose.Slides
for
.NET
3.5
Client
Pro·掌握實(shí)Co例pyr操ig作ht系20統(tǒng)04的-2實(shí)01現(xiàn)1
A方sp法ose
Pty
Ltd.4內(nèi)容簡(jiǎn)介設(shè)計(jì)目的設(shè)計(jì)內(nèi)容實(shí)施方法及要求時(shí)間安排輔導(dǎo)Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.5設(shè)計(jì)內(nèi)容(1)要求熟悉和理解Linux編程環(huán)境內(nèi)容Evaluation
only.ated
w編it寫(xiě)h一As個(gè)poC程s程e序.S,li使d用esLifnourx.下N的ET圖3形.5庫(kù)C,li分en窗t口Pro顯示三C三o個(gè)py并ri發(fā)g進(jìn)ht程2的00運(yùn)4-行2。011
Aspose
Pty
Ltd.6設(shè)計(jì)內(nèi)容(2)要求熟煉使用Linux的系統(tǒng)調(diào)用內(nèi)容Evaluation
only.ated
w編it寫(xiě)h一As個(gè)poC程s程e序.S,li使d用es文f件or系.統(tǒng)NE的T系3.統(tǒng)5調(diào)Cl用ie實(shí)n現(xiàn)t
Pro顯示文C文o本py文ri件g的ht功2能00。4-2011
Aspose
Pty
Ltd.7設(shè)計(jì)內(nèi)容(3)要求掌握添加系統(tǒng)調(diào)用的方法Evaluation
only.ated內(nèi)w容ith
Aspose.Slides
for
.NET
3.5
Client
Pro·添加C一op個(gè)y新ri的gh系t統(tǒng)20調(diào)0用4-2011
Aspose
Pty
Ltd.·編寫(xiě)一個(gè)使用新增系統(tǒng)調(diào)用功能的應(yīng)用程序。8設(shè)計(jì)內(nèi)容(4)要求理解和分析/proc文件Evaluation
only.ated內(nèi)w容ith
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.·了解/proc文件的特點(diǎn)和使用方法·監(jiān)控系統(tǒng)狀態(tài),顯示系統(tǒng)中若干部件的使用情況·用圖形界面顯示系統(tǒng)監(jiān)控狀態(tài)9設(shè)計(jì)內(nèi)容(5)要求理解和掌握文件系統(tǒng)的設(shè)計(jì)方法(選做)Evaluation
only.ated內(nèi)w容ith
Aspose.Slides
for
.NET
3.5
Client
Pro·設(shè)計(jì)C、op實(shí)y現(xiàn)ri一gh個(gè)t模20擬0的4-文20件11系A(chǔ)統(tǒng)spose
Pty
Ltd.·例如:·最簡(jiǎn)單的方法:用一個(gè)文件實(shí)現(xiàn)所有的功能?!?fù)雜一點(diǎn)的方法:采用庫(kù)文件的形式實(shí)現(xiàn)。10設(shè)計(jì)內(nèi)容(6)自選項(xiàng)目Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.11內(nèi)容1-4內(nèi)容5內(nèi)容5選做其中1項(xiàng);Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.12內(nèi)容簡(jiǎn)介設(shè)計(jì)目的設(shè)計(jì)內(nèi)容Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
Pro實(shí)施方法Co及pyr要ig求ht
2004-2011
Aspose
Pty
Ltd.時(shí)間安排輔導(dǎo)13實(shí)施方法及要求提交文本的課程設(shè)計(jì)報(bào)告,內(nèi)容包括調(diào)試記錄和程序清單(附注釋)。提交時(shí)間:2015.3.20
交B519室每位同學(xué)都必須獨(dú)立完成課程設(shè)計(jì)內(nèi)容。上機(jī)考核演示所完成系統(tǒng)E,v并al回ua答ti老o師n
o的n問(wèn)ly題.。ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.14實(shí)施方法及要求(續(xù))支持借鑒和學(xué)習(xí)已有的優(yōu)秀知識(shí)!Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
Pro反對(duì)Co全py盤rig拷ht
2貝004,-20不11求Asp甚ose解Pt!y
Ltd.
吸收和消化他人經(jīng)驗(yàn),做自己的課程設(shè)計(jì)!15內(nèi)容簡(jiǎn)介設(shè)計(jì)目的設(shè)計(jì)內(nèi)容時(shí)間安排輔導(dǎo)Evaluation
only.ated實(shí)w施it方h法As及p要os求e.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.16時(shí)間安排課程設(shè)計(jì)時(shí)間:課程安排的上機(jī)時(shí)間Evaluation
only.ate考d考w核ith
Aspose.Slides
for
.NET
3.5
Client
Pro現(xiàn)場(chǎng)考查Copyright
2004-2011
Aspose
Pty
Ltd.時(shí)間:2周周日17聯(lián)絡(luò)方式辦公室電話slyx@Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.18內(nèi)容簡(jiǎn)介設(shè)計(jì)目的設(shè)計(jì)內(nèi)容Evaluation
only.ated實(shí)w施i方th法A及s要po求se.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.時(shí)間安排輔導(dǎo)19課程設(shè)計(jì)輔導(dǎo)Linux系統(tǒng)的相關(guān)知識(shí)·以Redhat
Linux
9.0為例Evaluation
only.ated進(jìn)w程it并h
發(fā)A發(fā)spose.Slides
for
.NET
3.5
Client
Pro添加1個(gè)系Co統(tǒng)py調(diào)ri用ght
2004-2011
Aspose
Pty
Ltd.添加設(shè)備驅(qū)動(dòng)程序/proc文件分析20Linux系統(tǒng)的相關(guān)知識(shí)Linux版本
Linux通過(guò)簡(jiǎn)單的編號(hào)來(lái)區(qū)別內(nèi)核的穩(wěn)定版和開(kāi)發(fā)版。每個(gè)版本用三個(gè)數(shù)字Ev描a述lu,a由ti圓o點(diǎn)n
分on隔l。y.前兩個(gè)數(shù)表ated
wi示th版A本s號(hào)po,s第e.三S個(gè)li數(shù)d表es示f發(fā)or布.號(hào)N,ET如32..45.2C0l。ient
Pro如果第C二op個(gè)y數(shù)ri為g偶ht數(shù)2,00則4表-2示0穩(wěn)11定A的s內(nèi)po核s;e
否Pt則y,L表td.示開(kāi)發(fā)中的內(nèi)核。穩(wěn)定版的發(fā)布主要用來(lái)糾正用戶所報(bào)告的錯(cuò)誤,但實(shí)現(xiàn)內(nèi)核的主要算法和數(shù)據(jù)結(jié)構(gòu)基本不變。然而,開(kāi)發(fā)版本間可能存在很大的差異。21Linux系統(tǒng)的常用目錄文件目錄結(jié)構(gòu)——樹(shù)型結(jié)構(gòu)常用目錄有:/dev
Linux的所有設(shè)E備v文al件u,at如i/odnevo/nhldya代.表第一個(gè)物ated
wi理th
Aspose.Slides
for
.NET
3.5
Client
ProIDEC硬op盤y。right
2004-2011
Aspose
Pty
Ltd./etc
系統(tǒng)管理所需要的配置文件和子目錄。/lib
系統(tǒng)最基本的動(dòng)態(tài)鏈接共享庫(kù),幾乎所有的應(yīng)用程序都需要用到這些共享庫(kù)。22Linux系統(tǒng)的常用目錄/usr/man/usr/src幫助文檔的存放目錄Linux的源代碼目錄(續(xù))/usr
應(yīng)用程序和文件幾乎都存放在這個(gè)目錄下。其中包含以下子目錄:/usr/include開(kāi)發(fā)E發(fā)v和al編u譯at應(yīng)i用on程o序n所ly需.的頭文件ated
w?it/husArs/lpiobse.S常li用d的es動(dòng)f態(tài)o鏈r
接.N共E享T
庫(kù)3.和5靜Cl態(tài)i檔en案t庫(kù)Pro/usrC/loopcyarl
ig一h般t
用20戶0的4-目2錄01,1在As這p里os安e裝P軟ty件L最t適d.合23Linux系統(tǒng)的核心源碼Linux核心源代碼位于/usr/src/linux下:arch
CPU類型相關(guān)的核心代碼。每一個(gè)子目錄代表一種CPU類型,例如i386E就va是l關(guān)ua于tIinotneloCnPlUy及.與之相兼容ated
wi的th體A系s結(jié)po構(gòu)s的e.子S目li錄d;es
for
.NET
3.5
Client
ProdriversC所o所p有yr的i設(shè)gh備t驅(qū)2動(dòng)00程4序-2;0每1種1驅(qū)As動(dòng)p程os序e又P各ty占L用t一d.個(gè)子目錄,如/block下為塊設(shè)備驅(qū)動(dòng)程序include
編譯核心所需要的大部分頭文件。與平臺(tái)無(wú)關(guān)
的頭文件在include/linux子目錄下,與Intel
CPU相關(guān)的頭文件在include/asm-i386子目錄下;24Linux系統(tǒng)的核心源碼(續(xù))Linux核心源代碼還包括:InitEvaluation
only.ated
wi包th含A核sp心os的e初.S始li化de代s碼fo,r包.N含ET兩3個(gè).5文C件lient
Pro
main.Cco和pyvreirgsihiotn2.0c0,4這-2是01研1究As核po心s如e
P何t工y工L作td的.一個(gè)非常好的起點(diǎn);25Linux系統(tǒng)的核心源碼(續(xù))mm:
所有獨(dú)立于CPU體系結(jié)構(gòu)的內(nèi)存管理代碼,如頁(yè)式存儲(chǔ)管理中內(nèi)存的分配和釋放等,與體系結(jié)構(gòu)相關(guān)的內(nèi)存管E理v代al碼ua則ti位o于n
oanrclchy/.*/mm/下;atedkewrintehl:As主po要s的e.核Sl心id代e碼s
f,o此r.目N錄ET下3的.的5文Cl件i實(shí)en現(xiàn)t
了Pro大多數(shù)LCLionpuyxr系ig統(tǒng)ht的2內(nèi)00核4函-2數(shù)01,1其As中po最s重e重P要ty的L文td件.當(dāng)屬進(jìn)程調(diào)度sched.c,同樣,和體系結(jié)構(gòu)相關(guān)的代碼在arch/*/kernel中。26課程設(shè)計(jì)輔導(dǎo)Linux系統(tǒng)的相關(guān)知識(shí)·以Redhat
Linux
9.0為例進(jìn)程并發(fā)/proc文件分析Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
Pro添加系統(tǒng)調(diào)C用opyright
2004-2011
Aspose
Pty
Ltd.添加設(shè)備驅(qū)動(dòng)程序27進(jìn)程并發(fā)pid=fork():創(chuàng)建子進(jìn)程。返回值:0
從子進(jìn)程返回,>0
從父進(jìn)程返回exit進(jìn)程自我終止,進(jìn)入僵死狀態(tài),仍然保留ask_struct結(jié)構(gòu)。wait()等待進(jìn)程終止(由父進(jìn)程調(diào)用)exec()執(zhí)行一個(gè)可執(zhí)行程序(文件)Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.28課程設(shè)計(jì)輔導(dǎo)Linux系統(tǒng)的相關(guān)知識(shí)·以Redhat
Linux
9.0為例Evaluation
only.ated
進(jìn)wi程th并A發(fā)spose.Slides
for
.NET
3.5
Client
Pro添加系統(tǒng)Co調(diào)py用right
2004-2011
Aspose
Pty
Ltd.添加設(shè)備驅(qū)動(dòng)程序/proc文件分析29添加系統(tǒng)調(diào)用核心態(tài)
操作系統(tǒng)核心提供用戶態(tài)
函數(shù)庫(kù)或用戶自己·系統(tǒng)調(diào)用·普通的函數(shù)調(diào)用提供Linux系統(tǒng)調(diào)用機(jī)制·Linux內(nèi)核中設(shè)置了一組用于實(shí)現(xiàn)各種系統(tǒng)功能的子程序,稱為E為v系al統(tǒng)u調(diào)at用io。n
only.ated
wi·th用A戶s可po以se通.過(guò)Sl系i統(tǒng)de調(diào)s用fo命r令.N在E自T
己3.的5應(yīng)Cl用i程en序t
Pro中調(diào)C用op它y們r(jià)i。ght
2004-2011
Aspose
Pty
Ltd.系統(tǒng)調(diào)用與普通函數(shù)調(diào)用的區(qū)別30添加系統(tǒng)調(diào)用(續(xù))Linux系統(tǒng)調(diào)用機(jī)制·int
0x80定義好的代碼中執(zhí)行:跳轉(zhuǎn)到系統(tǒng)調(diào)用的總?cè)搿は到y(tǒng)調(diào)用是靠一些宏,一張系統(tǒng)調(diào)用表,一個(gè)系統(tǒng)調(diào)用入口來(lái)完成的。Evaluation
only.ated
with
Asp使o用se寄.S存l器id中e適s適f當(dāng)o的r
值.N跳ET轉(zhuǎn)3到.內(nèi)5
C核l中ie事n先t
Pro口sCyosptyemr_icgahltl,20檢0查4-系20統(tǒng)1調(diào)1
用As號(hào)po,s再e
查Pt找y系Ltd.統(tǒng)調(diào)用表sys_call_table,調(diào)用內(nèi)核函數(shù),最后返回。31添加系統(tǒng)調(diào)用(續(xù))returnnumber;
//該系統(tǒng)調(diào)用僅返回一個(gè)整型值}步驟_1
添加源代碼編寫(xiě)添加到內(nèi)核中Ev的a源l程ua序t,i函on數(shù)o名n以lsyy.s_開(kāi)頭。ated
with
Aspose.Slides
for
.NET
3.5
Client
Pro如:mycall(int
num),在/usr/src/linux/kernel/sys.件C中o添p加yr如i下g代h代t碼2:004-2011
Aspose
Pty
Ltd.asmlinkage
int
sys_mycall(int
number){32添加系統(tǒng)調(diào)用(續(xù))步驟_2
連接新的系統(tǒng)調(diào)用使內(nèi)核的其余部分知道該系統(tǒng)調(diào)用的存在。為此,需編輯兩個(gè)文件:#define
_NR_name
nnn這里,name:系統(tǒng)調(diào)用名;nnn:系統(tǒng)調(diào)用對(duì)應(yīng)的號(hào)碼,不能與內(nèi)核自身的系統(tǒng)調(diào)用號(hào)相同?!?/p>
/usr/src/linux/arch/i386/kernel/entry.S——對(duì)sys_call進(jìn)行初始化(增加新的內(nèi)核函數(shù)的指針).long
SYMBOL_NAME(sys_mycall)Evaluation
only.ated
wit·h/uAssr/psorcs/eli.nSuxl/iindcelusdef/aosrm-.i3N8E6/Tun3i.st5d.Ch—li—e系n統(tǒng)t調(diào)P用r清o每個(gè)C系o統(tǒng)p調(diào)y調(diào)r用i分g配h唯t
一2號(hào)00碼4)-2011
Aspose
Pty
Ltd.33添加系統(tǒng)調(diào)用(續(xù))#make
config
//基于文本的傳統(tǒng)配置界面#make
clean
//清除以前編譯的目標(biāo)文件#make
bzImage//編譯內(nèi)核,也可采用make
zImage·編譯生成的內(nèi)核文件為/usr/src/linux/arch/i386/boot/bzImage步驟_3
重建Linux內(nèi)核Evaluation
only.ated
wit·h
以Asrpooots身e.份S進(jìn)li入d/eussrf/osrrc./NlEinTu3x目.5錄C,li重e建nt內(nèi)P核roC#moapkeydreipght/2/0檢0驗(yàn)4內(nèi)-2核0源1代1碼A文sp件o的s依e
賴Pt性y和L完td.整性34添加系統(tǒng)調(diào)用(續(xù))步驟_4
重啟內(nèi)核·
將/usr/src/linux/arch/i386/boot/bzImage拷貝到/boot/bzImage·
配置啟動(dòng)文件若采用lilo,修改/etc/lilo.conf,添加新的引導(dǎo)內(nèi)核label=Linuxtestread-only若采用grub,修改/etc/grub.conf,添加新的引導(dǎo)內(nèi)核title
Linuxtestroot(hd0,4)kernel
/boot/bzImage
ro
root=/dev/hda5initrd
/boot/initrd-2.4.18-3.img·
重啟后,出現(xiàn)Linuxtest選項(xiàng),選擇它進(jìn)入新的內(nèi)核Evaluation
only.ated
with
Aismapgeo=/sboeot./bSzImlagie
de//s上面f編o譯r生成.的N內(nèi)E核T映象3.5
Client
ProrCooot=p/dyevr/hidag5//給該系統(tǒng)取個(gè)名字ht
2//0根0目4錄-所2在的0分1區(qū)1,A可用s命p令odsf查e看Pty
Ltd.35_syscall1(int
mycall,int
ret),講這個(gè)函數(shù)時(shí)一定要強(qiáng)調(diào),syscall后面緊緊跟了一個(gè)1,這個(gè)1時(shí)系統(tǒng)調(diào)用所需要的參數(shù)。添加系統(tǒng)調(diào)用(續(xù))步驟_5
使用新的系統(tǒng)調(diào)用·應(yīng)用程序app.c中調(diào)用新添加的系統(tǒng)調(diào)用mycall:parameters為參數(shù)。如上面的宏中,第一個(gè)參數(shù)int表示返回值類型,第二個(gè)參數(shù)mycall為函數(shù)名。第三個(gè)和第四個(gè)分別用來(lái)指定參數(shù)的類型和名稱編譯gcc–o
app
app.c#include<stdio.h>#include</usr/src/linux-2.4/
{
int
a
=
mycall(100);#include<errno.h>
return
0;Evailntumaaint(iintoanrgvo,
cnhlary*a.rgc[])ated
withincAlusdep/aosms/ueni.sStdl.hi>
despfriontrf(“.%Nd\En”T,a3);.5
Client
Pro_syscall1C(iontp,
ymyrcaillg,
ihntt,
r2et0)}04-2011
Aspose
Pty
Ltd.宏指令說(shuō)明:_syscalln(parameters):n表示系統(tǒng)調(diào)用所需參數(shù),36課程設(shè)計(jì)輔導(dǎo)Linux系統(tǒng)的相關(guān)知識(shí)·以Redhat
Linux
9.0為例Evaluation
only.ated
進(jìn)wi程th并A發(fā)spose.Slides
for
.NET
3.5
Client
Pro添加系統(tǒng)Co調(diào)py用right
2004-2011
Aspose
Pty
Ltd.添加設(shè)備驅(qū)動(dòng)程序/proc文件分析37添加設(shè)備驅(qū)動(dòng)程序內(nèi)核模塊LKM
Loadable
Kernel
ModulesLinux核心是一種monoElviatlhuiac類ti型on的o內(nèi)nl核y,.即單一的ated
w大i核th心A。spose.Slides
for
.NET
3.5
Client
Prolinux內(nèi)核C是op一yr個(gè)ig整h體t
結(jié)20構(gòu)04,-2因0此11向A內(nèi)sp核os添e加Pt或y者Lt刪d.除某些功能,都十分困難。為了解決這個(gè)問(wèn)題,引入了模塊機(jī)制,從而可以動(dòng)態(tài)的在內(nèi)核中添加或者刪除模塊。38添加設(shè)備驅(qū)動(dòng)程序(續(xù))模塊的實(shí)現(xiàn)機(jī)制·模塊初始化·模塊卸載int
init_module(
){
};int
clEeavnaulpu_amotdiuolne(o)n{l}y;.ated
w·it操h作Aspose.Slides
for
.NET
3.5
Client
Pro√unCsoigpnyerdilgohngts2y0s0_c4r-e2a0te1_1moAdsuploe
s(echPatr
y*nLatmed,.
unsigned
long
size);
//重新分配內(nèi)存√int
sys_delete_module
(char
*name);
//卸載√int
sys_query_module
(const
char
*name,
int
whvoid
*buf,
size_t
bufsize,
size_t
*ret);
/·頭文件:/usr/scr/linux/include/linux/module.h39添加設(shè)備驅(qū)動(dòng)程序(續(xù))完成:加載目標(biāo)文件調(diào)用create_module重新分配內(nèi)存執(zhí)行init_module(void)函數(shù)模塊的實(shí)現(xiàn)機(jī)制模塊加入:insmod
modulename.oEvaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.內(nèi)核符號(hào)用get_kernel_syms解析未解析的引用調(diào)用init_module初始化LKM->40添加設(shè)備驅(qū)動(dòng)程序(續(xù))查看模塊:lsmod結(jié)果:ModulePEagvgealuation
onUlsyed.
byated
wmiotdhulAesnpaomsee.Sl1i(d內(nèi)es存f信or息.)NET
30.(5使C用l用i次en數(shù)t
)Pro
Copyright
2004-2011
Aspose
Pty
Ltd.刪除模塊:rmmod
modulename41添加設(shè)備驅(qū)動(dòng)程序(續(xù))模塊編程實(shí)例·hello.c源碼·編譯gcc
–DMODULE
–D_KERNEL_
-I
/usr/src/linux_2.4.20-8/include
-cprintk("hello
world
!\n");return
0;void
cleanup_module()/*模塊卸載*/{
printk("
I
will
shut
down
myself
in
kernelmod!\n)";}#
include
"
linux/kernerl.h"#
include
"
linux/module.h"/*處理版本問(wèn)題CONFIG_MODVERSIONS
*/#
define
MODVERSIONS#
include
"
linux/version.h"#
end
ifint
init_module()/*模塊初始化*/{Evalpruinatkt("iI
hoavne
rounningliyn
a.kernel
mod!
\n");at#
ief
CdONFwIGi_MtODhVERASIsONpS=o=1
se.Slides}
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.42添加設(shè)備驅(qū)動(dòng)程序(續(xù))Linux支持的設(shè)備類型·字符設(shè)備——
c存取時(shí)沒(méi)有緩存E;v;a對(duì)l字ua符t設(shè)i備on發(fā)o出n讀l寫(xiě)y.請(qǐng)求時(shí),實(shí)ated
with際A的sIp/oO就se發(fā).生Sl了i。d如es:f鼠o標(biāo)r、.鍵NE盤T等3。.5
Client
Pro·塊設(shè)Co備py—r—ighbt
2004-2011
Aspose
Pty
Ltd.利用一塊系統(tǒng)內(nèi)存區(qū)域作緩沖區(qū),當(dāng)用戶進(jìn)程對(duì)設(shè)備請(qǐng)求能滿足用戶要求時(shí),返回請(qǐng)求數(shù)據(jù),否則,調(diào)用請(qǐng)求函數(shù)進(jìn)行實(shí)際的I/O操作。如:硬盤、軟盤、CD-ROM等。·網(wǎng)絡(luò)設(shè)備43添加設(shè)備驅(qū)動(dòng)程序(續(xù))設(shè)備驅(qū)動(dòng)程序一組常駐內(nèi)存的具有特權(quán)的共享庫(kù),是低級(jí)硬件處理例程。主設(shè)備號(hào)
從設(shè)備號(hào)Evaluation
only.ated
w每it個(gè)h設(shè)As備po文s件e.有Sl個(gè)id設(shè)e備s
f號(hào)or
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.44添加設(shè)備驅(qū)動(dòng)程序(續(xù))設(shè)備驅(qū)動(dòng)程序的功能·對(duì)設(shè)備初始化和釋放;Evaluation
only.ated
wit·h把A數(shù)sp據(jù)os從e內(nèi).S核l傳i傳d送es到f硬o件r件.和N從ET硬3件.5讀C取l數(shù)ie據(jù)nt;Pro·讀取Co應(yīng)py用r程ig序h傳t傳2輸0給04設(shè)-備2備0文11件A的s數(shù)p數(shù)o據(jù)se和P回t送y送L應(yīng)td.用程序請(qǐng)求的數(shù)據(jù);·檢測(cè)和處理設(shè)備出現(xiàn)的錯(cuò)誤。45添加設(shè)備驅(qū)動(dòng)程序(續(xù))Linux系統(tǒng)采用一組固定的入口點(diǎn)來(lái)實(shí)現(xiàn)驅(qū)動(dòng)設(shè)備的功能。·open入口點(diǎn):打開(kāi)設(shè)備。open子程序必須對(duì)將要進(jìn)行的I/O操作做好必要的準(zhǔn)備工作,如清除緩沖區(qū)等?!ead入口點(diǎn):從設(shè)備上讀數(shù)據(jù)?!elect入口點(diǎn):檢查設(shè)備,看數(shù)據(jù)是否可讀或設(shè)備是否可用于寫(xiě)數(shù)據(jù)。Evaluation
only.ated
wit·hcAlosspeo入s口e.點(diǎn)S:li關(guān)d閉es一f個(gè)o設(shè)r設(shè).備N。ET
3.5
Client
Pro·wriCtoep入y口ri點(diǎn)g:ht往2設(shè)0備04上-寫(xiě)2寫(xiě)0數(shù)11據(jù)A。spose
Pty
Ltd.·ioctl入口點(diǎn):執(zhí)行讀、寫(xiě)之外的操作。46這一頁(yè)比較繁瑣,可講可不講。添加設(shè)備驅(qū)動(dòng)程序(續(xù))入口點(diǎn)采用如下數(shù)據(jù)結(jié)構(gòu)實(shí)現(xiàn):int
(*flush)
(struct
file
*);int
(*release)
(struct
inode
*,
struct
file
*);int
(*fsync)
(struct
file
*,
struct
dentry
*,intdatasync);int
(*fasync)
(int,
struct
file
*,
int);unsigned
long,
loff_t
*);ssize
_t
(*se
nd
p
a
g
e)(stru
c
t
file
*,
struct
page#include</usr/src/linux/include/linux/fs.h>struct
file_operations{struct
module*owner;loff_t
(*llseek)
(struct
file
*,loff_t
,int);ssize_t
(*read)
(struct
file
*,char
*,size_t,lofifn_t
(**)l;o
ck)
(struct
file
*,
int,
struct
file_locloff_t
*); unsigned
long,
loff_t
*);unsigned
int
(*poll)
(struct
file
*,struct
poll_table_stru
c
t
*);int
(*ioctl)
(struct
inode
*,
struct
file
*,
size_t,
loff_t
*,
int);unsigned
int,
unsigned
long); unsigned
long
(*get_unmapped_area)(struct
fileint
(*mmap)
(struct
file
*,
struct
vm_area_struct
*);
unsigned
long,
unsigned
long,int
(*open)
(struct
inode
*,
struct
file
*); unsigned
long,
unsigned
long);}ssize_t
(*write)
(struct
file
*,
const
chEa
r
v*,asilzseus_itaz,e
_tt
i(*orena
dv
)o(nstlruyc
t
.file
*,
const
struct
ioaitn
te(*dre
awd
diirt)
(hstrAu
cst
pfiloe
s*,ev
o.idS*,lfiilldd
ier_st);sfsiozer_t
(.*wNriEteTv
)
(3st.ru5c
t
fCille
i*,
ec
onn
stt
stPrurc
toiCopyright
2004-2011
Aspose
Pty
Ltd.47添加設(shè)備驅(qū)動(dòng)程序(續(xù))注冊(cè)設(shè)備:向系統(tǒng)登記設(shè)備及驅(qū)動(dòng)程序的入口點(diǎn)·int
register_chrdev
(unsigned
int
major,
const
char
*nstruct
file_operations
*fops);//向系統(tǒng)的字符設(shè)備表登記一個(gè)字符設(shè)備//major:希望獲得的設(shè)備號(hào),為0時(shí)系統(tǒng)選擇一個(gè)沒(méi)有被占用的設(shè)備號(hào)返回。//name:設(shè)備名Evaluation
only.ated
with
A//sfoppso:s登e記.驅(qū)S動(dòng)l程i序d實(shí)e際s執(zhí)行f操o作r的.函N數(shù)E的T指針3.5
Client
Pro//登記成功,返回設(shè)備的主設(shè)備號(hào),否則,返回一個(gè)負(fù)值Copyright
2004-2011
Aspose
Pty
Ltd.·int
register_blkdev
(unsigned
int
major,
const
char
*nstruct
file_operations
*fops);//向系統(tǒng)的塊設(shè)備表登記一個(gè)塊設(shè)備48添加設(shè)備驅(qū)動(dòng)程序(續(xù))設(shè)備卸載·int
unregister_chrdev
(unsigned
int
major,
cochar
*name);//卸載字符設(shè)備·int
unregister_blkdev
(unsigned
int
major,
cochar
*name);//卸載塊設(shè)備Evaluation
only.ated
wit//hmaAjsorp:o要se卸.載Sl設(shè)i備d的es主f設(shè)o備r號(hào).NET
3.5
Client
Pro//namCe:op設(shè)y備r名i名ght
2004-2011
Aspose
Pty
Ltd.49添加設(shè)備驅(qū)動(dòng)程序(續(xù))添加設(shè)備驅(qū)動(dòng)程序的方法編寫(xiě)設(shè)備驅(qū)動(dòng)程序mydev.c在模塊的初始化init_module()中調(diào)用設(shè)備注冊(cè)函數(shù);gcc
-O2
-DMODULE
-D
KERNEL
-I/usr/src/linux-2.4.20-8/include
-c
mydev在模塊的卸載cleanuEpv_maolduualet(i)o中n調(diào)o用nl設(shè)y備.備的卸載函數(shù)。ated
w設(shè)it備h驅(qū)As動(dòng)p模os塊e的.S編l譯ides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.50添加設(shè)備驅(qū)動(dòng)程序(續(xù))加載設(shè)備驅(qū)動(dòng)模塊:
insmod
–f
mydev.o若加載成功,在文件/proc/devices中能看到新增加的設(shè)備,E包v括al設(shè)ua備ti名omnyodnelvy和.主設(shè)備號(hào)。ated
wi生th成A設(shè)sp備o文se件.Slides
for
.NET
3.5
Client
PromkCnoopdyr/didegvh/tt2es0t04c-22051410Aspose
Pty
Ltd.//其中,test為設(shè)備文件名,254為主設(shè)備號(hào),0為從設(shè)備號(hào),c表示字符設(shè)備51編寫(xiě)應(yīng)用程序,測(cè)試驅(qū)動(dòng)程序編譯gcc
hello.c
–o
hello添加設(shè)備驅(qū)動(dòng)程序(續(xù))if
(
testdev
==
-1
){printf("Cann"t
open
file
\n");exit(0);}read(testdev,buf,10);for
(i
=
0;
i
<
10;i++)printf("%
d\n",buf[i]);close(testdev);}#include
<stdio.h>#include
<sys/types.h>#include
<sys/stat.h>#include
<fcntl.h>int
main(){int
testdev;int
i;char
buf[10];testdev
=
open("/dev/test",O_RDWR);Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.52課程設(shè)計(jì)輔導(dǎo)Linux系統(tǒng)的相關(guān)知識(shí)·以Redhat
Linux
9.0為例進(jìn)程并發(fā)Evaluation
only.ated
with
Aspose.Slides
for
.NET
3.5
Client
Pro添加系統(tǒng)調(diào)C用opyright
2004-2011
Aspose
Pty
Ltd.添加設(shè)備驅(qū)動(dòng)程序/proc文件分析53/proc文件分析/procPROC文件系統(tǒng)是進(jìn)程文件系統(tǒng)和內(nèi)核文件系統(tǒng)的組成的復(fù)合體,是將內(nèi)核數(shù)據(jù)對(duì)象化為文件形式進(jìn)行存取的一種內(nèi)存文件系統(tǒng),是監(jiān)控Ev內(nèi)a核lu的a一ti種o用n
戶on接l口y口..它擁有一些ated
w特i殊th的A文s件po(s純e.文S本li)d,e,s從f中or可.以N獲ET取3系.統(tǒng)5
狀Cl態(tài)i信en息t。Pro系統(tǒng)信息Copyright
2004-2011
Aspose
Pty
Ltd.與進(jìn)程無(wú)關(guān),隨系統(tǒng)配置的不同而不同。命令procinfo可以顯示這些文件的大量信息。進(jìn)程信息系統(tǒng)中正在運(yùn)行的每一個(gè)用戶級(jí)進(jìn)程的信息。54/proc文件分析的中斷s最后一次的啟動(dòng)時(shí)間等。系統(tǒng)信息·/proc/cmd/line:內(nèi)核啟動(dòng)的命令行·/proc/cpuinfo:CPU信息·/proc/stat:CPU的Ev使a用lu情a況tiso磁n
盤onsl頁(yè)y.面s交換s所ated
w·it/hprAocs/pmoesmein.fSol:i內(nèi)d存es狀f態(tài)or的.有N關(guān)ET信3息.。5
Client
ProCopyright
2004-2011
Aspose
Pty
Ltd.進(jìn)程信息·/proc/$pid/stat·/proc/$pid/status·/proc/$pid/statm……etc55/proc文件分析監(jiān)控系統(tǒng)功能·通過(guò)讀取proc文件系統(tǒng),獲取系統(tǒng)各種信息,并以比較容易理解的方式顯示出來(lái)?!な褂肎TK+Linux下Ev的acl語(yǔ)ua言t開(kāi)io發(fā)n。only.ated
w·it具h(yuǎn)體A包sp括o:se.Slides
for
.NET
3.5
Client
Pro主機(jī)名Co、p系yr統(tǒng)i啟gh動(dòng)t時(shí)2間00、4系-2統(tǒng)0運(yùn)1運(yùn)1行A時(shí)sp間o、se版P本t號(hào)y
、Lt所d.有進(jìn)程信息、CPU類型、CPU的使用率、內(nèi)存使用率……參照W
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度柴油運(yùn)輸領(lǐng)域競(jìng)業(yè)禁止與供應(yīng)鏈管理合同
- 2025年度車庫(kù)抵押權(quán)質(zhì)押合同
- 二零二五年度中小企業(yè)發(fā)展信托合同模板
- 二零二五年度砂石運(yùn)輸及環(huán)保監(jiān)測(cè)服務(wù)合同
- 二零二五年度橋梁施工安全生產(chǎn)與責(zé)任追究合同
- 二零二五年度智能機(jī)器人產(chǎn)品研發(fā)保密合同
- 2025年度旅行社出境游業(yè)務(wù)代理合作協(xié)議書(shū)
- 二零二五年度連鎖飯店租賃經(jīng)營(yíng)合同
- 二零二五年度智能制造業(yè)無(wú)固定期限勞動(dòng)合同規(guī)范文本
- 家具定制測(cè)試與檢驗(yàn)合同
- 2025年黑龍江交通職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(kù)必考題
- 《馬克思主義與社會(huì)科學(xué)方法論》課件第一講馬克思主義與社會(huì)科學(xué)方法論導(dǎo)論
- 港華紫荊產(chǎn)品一覽
- 【保密工作檔案】外場(chǎng)試驗(yàn)保密工作方案
- 《民法典》婚姻家庭編解讀之夫妻個(gè)人財(cái)產(chǎn)第1063條PPT課件
- 2 遺傳圖繪制
- 人教部編版二年級(jí)語(yǔ)文下冊(cè)第六單元15古詩(shī)二首精品教案(集體備課)
- 三年級(jí)下冊(cè)數(shù)學(xué)教案-2.1速度、時(shí)間、路程-滬教版
- 400噸汽車吊性能表
- 墻面板安裝爬梯驗(yàn)算
- 矢量分析與場(chǎng)論講義
評(píng)論
0/150
提交評(píng)論