2023年山東大學(xué)操作系統(tǒng)實(shí)驗(yàn)七實(shí)驗(yàn)報(bào)告_第1頁(yè)
2023年山東大學(xué)操作系統(tǒng)實(shí)驗(yàn)七實(shí)驗(yàn)報(bào)告_第2頁(yè)
2023年山東大學(xué)操作系統(tǒng)實(shí)驗(yàn)七實(shí)驗(yàn)報(bào)告_第3頁(yè)
2023年山東大學(xué)操作系統(tǒng)實(shí)驗(yàn)七實(shí)驗(yàn)報(bào)告_第4頁(yè)
2023年山東大學(xué)操作系統(tǒng)實(shí)驗(yàn)七實(shí)驗(yàn)報(bào)告_第5頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

計(jì)算機(jī)科學(xué)與技術(shù)學(xué)院實(shí)驗(yàn)報(bào)告實(shí)驗(yàn)題目:ExtensionofAddrSpace學(xué)號(hào):日期:202371-25班級(jí):2023-3姓名:陶旭濤EmaiI:實(shí)驗(yàn)?zāi)康模涸诹私饬薔achos裝入并執(zhí)行單個(gè)用戶進(jìn)程的情況后,我們就需要進(jìn)一步完畢用戶內(nèi)存空間的擴(kuò)充以便多用戶程序同時(shí)駐留內(nèi)存,進(jìn)而使多用戶進(jìn)程并發(fā)執(zhí)行。硬件環(huán)境:Mem:3.9GCPU:Intel?Coretm2QuadCPUQ9500@2.83GHzx4Disk:15.5GB軟件環(huán)境:System:ubuntu12.O4LSTi386gcc:(Ubuntu4.6.3—1ubuntu5)4.6.3nachossystem實(shí)驗(yàn)環(huán)節(jié):要在Nachos中實(shí)現(xiàn)多用戶程序同時(shí)駐留內(nèi)存并發(fā)執(zhí)行,一方面涉及到Nachos的兩個(gè)系統(tǒng)調(diào)用:Exec()和Exit()o這兩個(gè)系統(tǒng)調(diào)用也是構(gòu)造父子進(jìn)程并發(fā)執(zhí)行的基礎(chǔ)。假設(shè)我們有以卜兩個(gè)用戶程序:../test/exec.c和../test/ha11.c../test/ha1t.c第65頁(yè)用戶進(jìn)程管理設(shè)計(jì)#incIude"syscaII.h"intmain()(HaltO}../test/exec.c#incIude"syscaII.h"intmain0(Spacidpid;pid=Exec("../test/haIt.noff");HaIt0)在文獻(xiàn)../test/exec,c第5行上的語(yǔ)句Exec是一條Nachos的系統(tǒng)功能調(diào)用,它的功能為裝入并執(zhí)行以其參數(shù)為名的可執(zhí)行文獻(xiàn),即創(chuàng)建一個(gè)新的用戶進(jìn)程。假設(shè)我們先執(zhí)行../test/exec.noff程序,則../test/exec.noff會(huì)在它還沒有執(zhí)行結(jié)束時(shí)又裝入并執(zhí)行此外一個(gè)程序halt,n。開,并與它同時(shí)駐留內(nèi)存.DEBUG(,dd\n,numPages,size);trst,setupthetranslationpageTable=newTranslationEntry[numPages];for(t=;t<numPages;t++){pageTable[t].vtrtualPage=t;pageTable[i].physicalPage=usermap->Find();pageTable[t].valid=TRUE;pageTable[t].use=FALSE;pageTable[i].dirty=FALSE;pageTable[t].readonly=FALSE;//aseparatepage,wecouldsetits//pagestoberead-onlypageTable[i].physicaIPage=usermap―>Find();避免從頭開始物理存儲(chǔ)覆蓋了前一個(gè)用戶程序的內(nèi)存內(nèi)容運(yùn)用Nachos在../userprog/bitmap.h中文獻(xiàn)定義的Bitmap類。運(yùn)用bitmap記錄和申請(qǐng)內(nèi)存物理幀,使不同的程序裝入到不同的物理空間中去,下面是對(duì)新的內(nèi)存分派存儲(chǔ)算法,改善了對(duì)多個(gè)用戶程序的同時(shí)進(jìn)駐內(nèi)存的支持if(noffH.code.size>){DEBUG(,'>.W\n,noffH.code.vtrtualAddr,noffH.code.size);intnunberofPages;nunberofPdgesMltvRoundUp(noffH.code.size,Pagesize);for(i=;t<nunberofPages;t**){prtntf(,pageTable[t].phystcalPage,PageStze);print",noffH.code.InFUeAddr+VPageStze);print”.PageStze);executable->ReadAt(?(Mchtne->natnMe?)ry[pdgeTable[t].phy$kalPage*PageStze]),PdgeSUe,noffH.code.tnFt.leAd<Jr*t*Pagestze);})if(noffH.tnttData.size>){DEBUG(,,noffH.tnttData.vtrtualAddr,noffH.tnttData.size);executable->fleadAt(4(Mchtne->nainHe?)ry[fK>ffH.tnttData.vtrtuaUddr]),noffH.initData.size,rx>ffH.tnttOata.tnFUeAddr);intnunberofP.firstP;nunberofP=dtvRoundup(noffH.tnttData.size,PageSlze);(Wr,PageStze);for(t?firstP;t<nuHl)erofP;t++){prtntf(,pageTable[t].phystcalPage,PageSlze);prtntf(,i)offH.tnttData.InFUeAddr+VPageSize);printf();executable->ReadAt(t(Aachtne->NtnNeRory[pageTable(t].phystcdlPage*PageStze]),PageStze,noffH.tnttData.tnFUeAddr+t*PageStze);))Print();)這是對(duì)Bi(Map的代碼修改,每次分派的時(shí)候要找到bitmap中的空閑頁(yè)進(jìn)行分派,而不能從0頁(yè)開始分派在AddressSpace類中聲明bi(map對(duì)象staticBitMap*mbitmap=newBitMap(NumPhysPages);voidBitMap::Prtnt()(printf(\n);for(inti=;i<numBits;t++)if(Test(t))prtntf(,t);prtntf();)//Thesearen'tneededuntiltheFILESYSassignment////BitMap::FetchFromFile//InitializethecontentsofabitmapfromaNachosfile.////"file"istheplacetoreadthebitmapfrom//voidBitMap::FetchFrom(OpenFtle*file)(file->ReadAt((char*)map,numWords*sizeof(unsigned),);)////BitMap::WrtteBack//StorethecontentsofabitmaptoaNachosfile.////"file"istheplacetowritethebitmapto//voidBttMap::WriteBack(OpenFtle*file)Ifile->WrtteAt((char*)map,numWords*sizeof(unsigned),);運(yùn)營(yíng)./nachos-x../test/exec.noffking@kingvm:~/nachos-3.4/code/lab7-8$./nachos-x../test/exec.noff★★★king@kingvm:~/nachos-3.4/code/lab7-8$./nachos-x../test/exec.noff★★★thread0looped0times***thread1looped0times★★★thread0looped1times★★★thread1looped1times★★★thread0looped2times★★★thread1looped2times***thread0looped3times★★★thread1looped3times★★★thread1looped4times★★★thread0looped4timestheallocatedphysicalAddress:?theaddressintheexecutablefile:40copysize128theallocatedphysicalAddress:128theaddresstntheexecutablefile:168copysize128theallocatedphysicalAddress:256theaddressintheexecutablefile:296copysize128pagetabledump:12pagestntotalVtrPage,PhysPagee,01,12,23,34,45,56,67,78,89,910,1011,11Exec—調(diào)用theallocatedphysicalAddress:1536theaddressintheexecutablefile:40copysize128theallocatedphysicalAddress:1664theaddressintheexecutablefile:168copysize128pagetabledump:10pagesintotalVirPage,PhysPage0,121,132,143,154,165,176,187,198,209,21Machinehalting!Ticks:total165,idle0,system140,user25DiskI/O:reads0,writes0ConsoleI/O:reads0,writes0Paging:faults0NetworkI/O:packetsreceived0,sent0Cleaningup...ktng

溫馨提示

  • 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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論