freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

操作系統(tǒng)實驗指導(dǎo)書(已修改)

2025-08-17 06:38 本頁面
 

【正文】 《 操作系統(tǒng)原理》實驗指導(dǎo)書羊四清 編 寫適用專業(yè): 計算機科學(xué)與技術(shù) 網(wǎng)絡(luò)工程 湖南人文科技學(xué)院計算機科學(xué)技術(shù)系 2008年 8 月前 言操作系統(tǒng)是計算機的核心和靈魂。操作系統(tǒng)軟件的設(shè)計對整個計算機的功能和性能起著至關(guān)重要的作用,所以此門課也是必不可少的,是面向計算機科學(xué)與技術(shù)、網(wǎng)絡(luò)工程、軟件工程等大多數(shù)計算機專業(yè)本科生開設(shè)的一門計算機專業(yè)課程。操作系統(tǒng)是計算機系統(tǒng)的核心,《操作系統(tǒng)》課程是計算機科學(xué)與技術(shù)專業(yè)的重要必修課。本課程的目的是使學(xué)生掌握現(xiàn)代計算機操作系統(tǒng)的基本原理、基本設(shè)計方法及實現(xiàn)技術(shù),具有分析現(xiàn)行操作系統(tǒng)和設(shè)計、開發(fā)實際操作系統(tǒng)的基本能力。操作系統(tǒng)實驗是操作系統(tǒng)課程的重要組成部分,屬于學(xué)科基礎(chǔ)實驗范疇。作為與相關(guān)教學(xué)內(nèi)容配合的實踐性教學(xué)環(huán)節(jié),應(yīng)在操作系統(tǒng)理論課教學(xué)過程中開設(shè)。操作系統(tǒng)是計算機科學(xué)與技術(shù)專業(yè)必修的專業(yè)基礎(chǔ)課程,操作系統(tǒng)實驗的作用是:理解操作系統(tǒng)的設(shè)計和實現(xiàn)思路,掌握典型算法。基本要求是:理解進程的概念,理解死鎖,掌握銀行家算法;掌握請求頁式存儲管理的實現(xiàn)原理及頁面置換算法。學(xué)生應(yīng)具有高級語言編程能力、具有數(shù)據(jù)結(jié)構(gòu)等基礎(chǔ)知識。說明:. 目錄實驗一 進程創(chuàng)建模擬 1實驗二 進程撤銷模擬 9實驗三 P、V 原語的模擬實現(xiàn) 10實驗四 帶優(yōu)先級的時間片輪換的進程調(diào)度算法的實現(xiàn) 16實驗五 銀行家算法模擬 26實驗六 連續(xù)動態(tài)內(nèi)存管理模擬實現(xiàn) 29實驗七 請求頁式存儲管理中常用頁面置換算法模擬 31實驗八 SCAN 磁盤調(diào)度模擬實現(xiàn) 36實驗九 UNIX基本操作 373實驗一 進程創(chuàng)建模擬實驗學(xué)時:2實驗類型:驗證實驗要求:必修一、實驗?zāi)康?) 理解進程創(chuàng)建相關(guān)理論;2) 掌握進程創(chuàng)建方法;3) 掌握進程相關(guān)數(shù)據(jù)結(jié)構(gòu)。二、實驗內(nèi)容本實驗針對操作系統(tǒng)中進程創(chuàng)建相關(guān)理論進行實驗。要求實驗者輸入實驗指導(dǎo)書提供的代碼并進行測試。代碼簡化了進程創(chuàng)建的多個步驟和內(nèi)容。進程的樹形結(jié)構(gòu)采用廣義二叉樹的方式進行存儲。三、實驗原理1)進程控制塊為了描述和控制進程的運行,系統(tǒng)為每個進程定義了一個進程控制塊(PCB),它是進程實體的一部分,是操作系統(tǒng)管理進程最重要的數(shù)據(jù)結(jié)構(gòu)。其主要包含四類信息:(1) 進程標(biāo)識符它唯一地標(biāo)識一個進程。通常包括進程號 pid,父進程號 ppid 和用戶號 uid。(2) 處理機狀態(tài)處理器的狀態(tài)通常由處理機的各種寄存器中的內(nèi)容組成。PCB 存放中斷(阻塞,掛起)時的各寄存器值,當(dāng)該進程重新執(zhí)行時,可以從斷點處恢復(fù)。主要包括: a) 通用寄存器; b) 指令計數(shù)器; c) 程序狀態(tài)字 PSW; d) 用戶棧指針。(3) 進程調(diào)度信息 a) 進程狀態(tài); b) 進程優(yōu)先級(用于描述優(yōu)先使用 cpu 級別的一個整數(shù),高優(yōu)先級的進程先得到cpu,通常情況下,優(yōu)先值越小優(yōu)先級越高); c) 其它信息(等待時間、總執(zhí)行時間等); d) 事件(等待原因)。(4) 進程控制信息 a) 程序和數(shù)據(jù)的地址(程序在內(nèi)存和外存中的首址); b) 進程同步和通信機制; c) 資源列表(進程除 CPU 以外的所有資源); d) 鏈接指針(進程隊列中指向下一個進程的 PCB 首址)。2) 進程創(chuàng)建流程 (1) 申請空白 PCB 為新進程申請獲得唯一的數(shù)字標(biāo)識符,并從 PCB 集合中索取一個空白 PCB。如果無空白PCB,可以創(chuàng)建一個新的 PCB。在本實驗中,每次動態(tài)創(chuàng)建 PCB。 (2) 為新進程分配資源 為新進程分配內(nèi)存空間和棧空間。 (3) 初始化進程控制塊 a) 初始化標(biāo)識信息; b) 初始化處理機狀態(tài)信息; c) 初始化處理機控制信息。 (4) 將新進程插入就緒隊列P1P2P3P4P5P6P7P8P9P10P11P12 3) 進程樹 圖 11 進程樹 進程樹用于描述進程家族關(guān)系,如圖 11 中可以看出,進程 P1 創(chuàng)建了進程 PPPP5,而 P2 又創(chuàng)建了 PPP8 …… 。在進程創(chuàng)建過程中,需要對每一個新增加的進程加入到進程樹中,有了清晰的父子關(guān)系,可以使資源繼承或進程刪除等操作變得很方便。4) 進程總鏈它是一個 PCB 鏈表,每一個新創(chuàng)建的進程必須把其 PCB 放入總鏈中,該總鏈可以對破壞的進程樹進行修復(fù),也方便 PCB 查找。四、程序清單 文件ifndef basic_hincludeincludeincludedefine basic_hchar *errormsg[256]。//process control blockstruct pcb{ int pid。//process id int ppid。//parent process id int prio。//priority int state。//state int lasttime。//last execute time int tottime。 //totle execute time}。//process nodestruct pnode{ pcb *node。 pnode *sub。 pnode *brother。 pnode *next。}。//信號量struct semphore{ char name[5]。 //名稱 int count。//計數(shù)值 int curpid。//當(dāng)前進程 id pnode *wlist。 //等待鏈表}。define geterror(eno) printf(%s\n,errormsg[eno]) void initerror(){ errormsg[0] = (char *)malloc(20)。 errormsg[0]=error mand!。 errormsg[1] = (char *)malloc(20)。 errormsg[1]=error parameter!。}//get a substring in string schar * substr(char *s,int start,int end){ char *s1。 int len = strlen(s)。 if(start0 || end=len || startend) return NULL。 s1=(char *)malloc(endstart+2)。 for(int i=0。i=endstart。i++) s1[i] = s[i+start]。 s1[i]=39。\039。 return s1。}//find the location of c in string sint instr(char *s,char c){ unsigned i。 for(i=0。istrlen(s)。i++) if(s[i]==c) return i。 return 1。}//change the string to array dataint * strtoarray(char *s){ int *a,count,x1。 unsigned int i。 char c, *s1,*s2。 if(!s) { printf(string can39。t be null!\n)。 return NULL。 } count=0。 s1=s。 for(i=0。istrlen(s1)。i++) if(s1[i]==39。,39。) count++。 count++。 a = (int *)malloc(count)。 c=39。,39。 for(i=0。icount。i++) { x1 = instr(s1,c)。 if(x1=0) s2=substr(s1,0,x11)。 else s2=s1。 a[i]=atoi(s2)。 if(c==39。,39。) s1=substr(s1,x1+1,strlen(s1)1)。 } return a。}endif源程序include pnode *proot。//system process tree rootpnode *plink。//system process link head//create processint createpc(int *para){ //add your code here pnode *p,*p1,*pp。 int pflag。 pflag=0。 for(p=plink。p。p=pnext) { if(pnodepid == para[0]) //check if this pid is already exist { printf(pid %d is already exist!\n,para[0])。 return 1。 } if(pnodepid == para[1]) //find parent pcb { pflag=1。 pp = p。 } } if(!pflag) { printf(parent id %d is not exist!\n,para[1])。 return 2。 }//init new pcbp1 = new pnode。p1node=new pcb。p1nodepid = para[0]。p1nodeppid = para[1]。p1nodeprio = para[2]。p1sub=NULL。p1next=NULL。p1brother=NULL。//add to process treeif(!ppsub) ppsub=p1。else{ for(p=ppsub。pbrother。p=pbrother)。 pbrother=p1。}// add to process linkfor(p=plink。pnext。p=pnext)。pnext=p1。return 0。}//show process detailvoid showdetail(){ //add your code here pnode *p,*p1。 p=plink。 for(。p。) //print all pcb info { printf(%d(prio %d):,pnodepid,pnodeprio)。 p1 = psub。 for(。p1。) //print sub pcb { printf(%d(prio %d),p1nodepid,p1nodeprio)。 p1 = p1brother。 } printf(\n)。 p = pnext。 } printf(\n)。}//don39。t changevoid main(){ initerror()。 short cflag,pflag。 char cmdstr[32]。 proot = new pnode。 prootnode=new pcb。 prootnodepid=0。 prootnodeppid=1。 prootnodeprio=0。 prootnext=NULL。 prootsub=NULL。 prootb
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號-1