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

正文內(nèi)容

嵌入式操作系統(tǒng)實驗報告(編輯修改稿)

2024-10-28 19:22 本頁面
 

【文章內(nèi)容簡介】 ct PCB_type{int pid。//進(jìn)程名 intstate。//進(jìn)程狀態(tài)2——表示“執(zhí)行”狀態(tài)1——表示“就緒”狀態(tài)0——表示“阻塞”狀態(tài)int cpu_time。//運(yùn)行需要的CPU時間(需運(yùn)行的時間片個數(shù))} 用PCB來模擬進(jìn)程;(2)設(shè)置兩個隊列,將處于“就緒”狀態(tài)的進(jìn)程PCB掛在隊列ready中;將處于“阻塞”狀態(tài)的進(jìn)程PCB掛在隊列blocked中。隊列類型描述如下:struct QueueNode{struct PCB_typePCB。Struct QueueNode *next。} 并設(shè)全程量:struct QueueNode *ready_head=NULL,//ready隊列隊首指針*ready_tail=NULL , //ready隊列隊尾指針*blocked_head=NULL,//blocked隊列隊首指針 *blocked_tail=NULL。//blocked隊列隊尾指針(3)設(shè)計子程序:start_state()。讀入假設(shè)的數(shù)據(jù),設(shè)置系統(tǒng)初始狀態(tài),即初始化就緒隊列和阻塞隊列。dispath()。模擬調(diào)度,當(dāng)就緒隊列的隊首進(jìn)程運(yùn)行一個時間片后,放到就緒隊列末尾,每次都是隊首進(jìn)程進(jìn)行調(diào)度,一個進(jìn)程運(yùn)行結(jié)束就從就緒隊列中刪除,當(dāng)?shù)絫個時間片后,喚醒阻塞隊列隊首進(jìn)程。calculate()。就緒進(jìn)程運(yùn)行一次,usecpu加1,當(dāng)就緒隊列為空時unusecpu加1,CPU利用率為use_cpu/(use_cpu+unuse_cpu)。5源代碼:include includestruct PCB_type {int pid。//進(jìn)程名intstate。//進(jìn)程狀態(tài)//2表示“執(zhí)行”狀態(tài)//1表示“就緒”狀態(tài)//0表示“阻塞”狀態(tài)int cpu_time。//運(yùn)行需要的CPU時間(需運(yùn)行的時間片個數(shù))}。struct QueueNode{struct PCB_typePCB。struct QueueNode *next。}。struct QueueNode *ready_head=NULL,//ready隊列隊首指針*ready_tail=NULL,//ready隊列隊尾指針*block_head=NULL,//blocked隊列隊首指針*block_tail=NULL。//blocked隊列隊尾指針int use_cpu,unuse_cpu。void start_state()//讀入假設(shè)的數(shù)據(jù),設(shè)置系統(tǒng)初始狀態(tài) {int n,m。int i。struct QueueNode *p,*q。printf(“輸入就緒節(jié)點(diǎn)個數(shù)n:”)。scanf(“%d”,amp。n)。printf(“輸入阻塞節(jié)點(diǎn)個數(shù)m:”)。scanf(“%d”,amp。m)。p=(struct QueueNode *)malloc(sizeof(struct QueueNode))。pnext =NULL。ready_head=ready_tail=p。for(i=0。i{p=(struct QueueNode *)malloc(sizeof(struct QueueNode))。pnext =NULL。p=1。printf(“輸入就緒進(jìn)程%d的pid和cpu_time:”,i+1)。scanf(“%d%d”,amp。p,amp。p)。ready_tailnext=p。ready_tail=p。}q=(struct QueueNode *)malloc(sizeof(struct QueueNode))。qnext =NULL。block_head=block_tail=q。for(i=0。i{q=(struct QueueNode *)malloc(sizeof(struct QueueNode))。qnext=NULL。q=0。printf(“輸入阻塞進(jìn)程%d的pid和cpu_time:”,i+1)。scanf(“%d%d”,amp。q,amp。q)。block_tailnext=q。block_tail=q。}printf(“n處于就緒狀態(tài)的進(jìn)程有:n”)。p=ready_headnext。i=1。while(p){printf(“進(jìn)程%d的pid和cpu_time:%5d%5d%5dn“,i,p,p,p)。p=pnext。i++。} } void dispath()//模擬調(diào)度 {int x=0,t。use_cpu=0。unuse_cpu=0。printf(”輸入t:“)。scanf(”%d“,amp。t)。printf(”開始調(diào)度n“)。while(ready_head!=ready_tail||block_head!=block_tail){struct QueueNode *p,*q。if(ready_head!=ready_tail){p=ready_headnext。ready_headnext=pnext。pnext=NULL。if(ready_headnext==NULL){ready_tail=ready_head。}p=2。printf(”進(jìn)程%d調(diào)度t“,p)。state和use_cpu++。x++。p。if(p){ready_tailnext=p。ready_tail=p。}else{printf(”進(jìn)程%d完成t“,p)。free(p)。}}else{unuse_cpu++。x++。printf(”空閑一個時間片t“)。}if(x==tamp。amp。block_head!=block_tail){q=block_headnext。block_headnext=qnext。qnext=NULL。if(block_headnext==NULL){block_tail=block_head。}ready_tailnext=q。ready_tail=q。x=0。}} } void calculate()//計算CPU利用率 { printf(”ncpu的利用率%.2fn“,(float)use_cpu/(use_cpu+unuse_cpu))。} void main(){start_state()。dispath()。calculate()。} 6運(yùn)行結(jié)果:7實驗總結(jié):實驗幫我復(fù)習(xí)了數(shù)據(jù)結(jié)構(gòu)和C語言,且鞏固課本知識,知道了如何定義結(jié)構(gòu)體,如何在鏈接隊列中增刪節(jié)點(diǎn)。模擬進(jìn)程調(diào)度幫我們鞏固了進(jìn)程三狀態(tài)之間的變遷。懂得調(diào)式的重要性??傊覀兠靼琢死碚撀?lián)系實際。多看書,多上機(jī)。實驗三可變分區(qū)存儲管理1.目的和要求通過這次實驗,加深對內(nèi)存管理的認(rèn)識,進(jìn)一步掌握內(nèi)存的分配、回收算法的思想。2.實驗內(nèi)容閱讀教材《計算機(jī)操作系統(tǒng)》第四章,掌握存儲器管理相關(guān)概念和原理。編寫程序模擬實現(xiàn)內(nèi)存的動態(tài)分區(qū)法存儲管理。內(nèi)存空閑區(qū)使用自由鏈管理,采用最壞適應(yīng)算法從自由鏈中尋找空閑區(qū)進(jìn)行分配,內(nèi)存回收時假定不做與相鄰空閑區(qū)的合并。假定系統(tǒng)的內(nèi)存共640K,初始狀態(tài)為操作系統(tǒng)本身占用64K。在t1時間之后,有作業(yè)A、B、C、D分別請求8K、16K、64K、124K的內(nèi)存空間;在t2時間之后,作業(yè)C完成;在t3時間之后,作業(yè)E請求50K的內(nèi)存空間;在t4時間之后,作業(yè)D完成。要求編程序分別輸出tttt4時刻內(nèi)存的空閑區(qū)的狀態(tài)。3.實驗環(huán)境Windows操作系統(tǒng)、VC++ C語言模擬內(nèi)存分配和回收,要設(shè)置兩個鏈隊列,一個空閑區(qū)鏈和一個占用區(qū)鏈,空閑區(qū)鏈節(jié)點(diǎn)有起始地址,大小和指向下一節(jié)點(diǎn)的指針等數(shù)據(jù)域,占用區(qū)鏈節(jié)點(diǎn)有起始地址,大小,作業(yè)名和指向下一節(jié)點(diǎn)的指針等數(shù)據(jù)域,本實驗用最壞適應(yīng)算法,每次作業(yè)申請內(nèi)存都是從空閑鏈隊頭節(jié)點(diǎn)分配,如果相等,就刪除空閑頭結(jié)點(diǎn),如果小于申請的,就不分配,否則就劃分內(nèi)存給作業(yè),剩下的內(nèi)存大小,重新插入空閑鏈隊,按從大到小,接著把作業(yè)占用的內(nèi)存放到占用區(qū)鏈節(jié)點(diǎn)的末尾。每次作業(yè)運(yùn)行完,就要回收其占用的內(nèi)存大小,把作業(yè)節(jié)點(diǎn)按從大到小插入到空閑鏈隊中。:include include struct freelinkNode{ int len。int address。struct freelinkNode *next。}。struct busylinkNode{ char name。int len。int address。struct busylinkNode *next。}。struct freelinkNode *free_head=NULL。//自由鏈隊列(帶頭結(jié)點(diǎn))隊首指針struct busylinkNode *busy_head=NULL。//占用區(qū)隊列隊(帶頭結(jié)點(diǎn))首指針struct busylinkNode *busy_tail=NULL。//占用區(qū)隊列隊尾指針 void start(void)/* 設(shè)置系統(tǒng)初始狀態(tài)*/ { struct freelinkNode *p。struct busylinkNode *q。free_head=(struct freelinkNode*)malloc(sizeof(struct freelinkNode))。free_headnext=NULL。// 創(chuàng)建自由鏈頭結(jié)點(diǎn)busy_head=busy_tail=(struct busylinkNode*)malloc(sizeof(struct busylinkNode))。busy_headnext=NULL。// 創(chuàng)建占用鏈頭結(jié)點(diǎn)p=(struct freelinkNode *)malloc(sizeof(struct freelinkNode))。paddress=64。plen=64064。//OS占用了64Kpnext=NULL。free_headnext=p。q=(struct busylinkNode *)malloc(sizeof(struct busylinkNode))。qname=39。S39。/* S表示操作系統(tǒng)占用*/qlen=64。qaddress=0。qnext=NULL。busy_headnext=q。busy_tail=q。} void requireMemo(char name, int require)/*模擬內(nèi)存分配*/ { freelinkNode *w,*u,*v。busylinkNode *p。if(free_headnextlen=require){p=(struct busylinkNode*)malloc(sizeof(struct busylinkNode))。pname=name。paddress=free_headnextaddress。plen=require。pnext=NULL。busy_tailnext=p。busy_tail=p。} elseprintf(”Can39。t allocate“)。w=free_headnext。free_headnext=wnext。if(wlen==require){free(w)。} else {waddress=waddress+require。wlen=wlenrequire。}u=free_head。v=free_headnext。while((v!=NULL)amp。amp。(vlenwlen)){u=v。v=vnext。}unext=w。wnext=v。} void freeMemo(char name)/* 模擬內(nèi)存回收*/ { int len。int address。busylinkNode *q,*p。freelinkNode *w,*u,*v。q=busy_head。p=busy_headnext。while((p!=NULL)amp。amp。(pname!=name)){q=p。p=pnext。}if(p==NULL){printf(”%c is not exist“,name)。} else{if(p==busy_tail){busy_tail=q。}else{qnext=pnext。len=plen。address=paddress。free(p)。w=(struct freelinkNode*)malloc(sizeof(struct freelinkNode))。wlen=len。waddress=address。u=free_head。v=free_headnext。while((v!=NULL)amp。amp。(vlenlen)){ u=v。v=vnext。}unext=w。wnext=v。} } } void past(int time)/* 模擬系統(tǒng)過了time 時間*/ { printf(”過了時間%d后:n“,time)。} void printlink()/* 輸出內(nèi)存空閑情況(自由鏈的結(jié)點(diǎn))*/ {freelinkNode *p。printf(”內(nèi)存的空閑情況為:n“)。p=(struct freelinkNode *)malloc(sizeof(struct freelinkNode))。p=free_headnext。while(p!=NULL){printf(”內(nèi)存的起始地址和內(nèi)存的大小%5dt%
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1