91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

操作下系統(tǒng)的實驗報告,第一個實驗選的是那個設(shè)計一個先來先服務(wù)的調(diào)度算法

資源截圖

代碼片段和文件信息

#include
#include
//#include?
#define?N?20 //進(jìn)程名字最多支持20個字符

typedef?struct?pcb
{
char?pname[N]; //進(jìn)程名字
int?runtime; //進(jìn)程估計運行的時間
int?arrivetime; //進(jìn)程到達(dá)時間
char?state; //進(jìn)程狀態(tài)
struct?pcb?*next;//連接指針
}PCB;

PCB?head_input; //鏈表的頭
PCB?*queue_head*queue_end;//模擬隊列的頭和尾指針
//FILE?*f; //文件保存
int?sum_turnaroundtime=0;//總周轉(zhuǎn)時間
int?num; //總進(jìn)程數(shù)目
static?char?R=‘r‘C=‘c‘;
unsigned?long?current; //系統(tǒng)當(dāng)前時間,按秒計算
void?inputprocess(); //創(chuàng)建進(jìn)程的子函數(shù),按照到達(dá)時間進(jìn)入隊列
void?runreadyprocess(); //運行就緒的隊列


void?runreadyprocess()
{
int?i=0timeruntime1;
PCB?*p1;
while(queue_end!=NULL)
{
i++;
p1=queue_end;
while((unsigned?long)p1->arrivetime>current)//如果到達(dá)時間大于當(dāng)前時間,等待
current++;

printf(“NO.?%3d?process?%s?has?started!\n“ip1->pname);
time=0;runtime1=p1->runtime;
while(p1->runtime>0)//運行進(jìn)程,先來先服務(wù),運行完先來的,再運行下一個
{
p1->runtime--;
time++;
current++;
printf(“NO.?%3d?process?%s?has?run?%ds??still?has?%ds?to?complete!\n“ip1->pnametimeruntime1-time);
}
p1->state=C;????????//進(jìn)程運行完,更改狀態(tài)

printf(“NO.?%3d?process?%s?has?completed!\n“ip1->pname);
printf(“NO.?%3d?process?%s‘s?turnaround_time?is?:?%d\n“ip1->pnamecurrent-p1->arrivetime);
printf(“\n“);
sum_turnaroundtime+=current-p1->arrivetime;

queue_end=queue_head->next;
queue_head=queue_end;
}

}


void?inputprocess()
{
PCB?*p1*p2;

printf(“How?many?processes?do?you?want?to?run:?“);
//fprintf(f“How?many?processes?do?you?want?to?run:?“);
scanf(“%d“&num);
//fprintf(f“%d\n“&num);


p1=&head_input;
p2=p1;
p1->next=new?PCB;
p1=p1->next;
for(int?i=0;i {
printf(“NO.?%3d?processes?input?pname:?“i+1);
//fprintf(f“NO.?%3d?processes?input?pname:?“i+1);
scanf(“%s“p1->pname);
//fprintf(f“%s\n“p1->pname);

printf(“NO.?%3d?processes?runtime:?“i+1);
//fprintf(f“NO.?%3d?processes?runtime:?“i+1);
scanf(“%d“&(p1->runtime));
//fprintf(f“%d\n“&(p1->runtime));

printf(“NO.?%3d?processes?arrivetime:?“i+1);
//fprintf(f“NO.?%3d?processes?arrivetime:?“i+1);
scanf(“%d“&(p1->arrivetime));
//fprintf(f“%d\n\n“&(p1->arrivetime));
printf(“\n“);

p1->state=R;
p1->next=new?PCB;
p2=p1;
p1=p1->next;
}
delete?p1;
p1=NULL;
p2->next=NULL;
}

void?main()
{
//f=fopen(“result.txt““w“);
current=0;
inputprocess();

queue_head=&head_input;
queue_end=queue_head->next;
queue_head=queue_end;

runreadyprocess();

printf(“The?average?turnaround_time?of?all?the?processes?is?:??%d\n“sum_turnaroundtime/num);
//system(?“type?result.txt“?);?
}







?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2827??2010-03-26?14:34??12110703-20072844-張戰(zhàn)友-操作系統(tǒng)模擬算法實驗\ProcessFifo.cpp

?????文件?????134144??2010-03-26?14:48??12110703-20072844-張戰(zhàn)友-操作系統(tǒng)模擬算法實驗\操作系統(tǒng)實驗報告-12110703-20072844-張戰(zhàn)友.doc

?????目錄??????????0??2010-03-26?14:49??12110703-20072844-張戰(zhàn)友-操作系統(tǒng)模擬算法實驗

-----------?---------??----------?-----??----

???????????????136971????????????????????3


評論

共有 條評論

相關(guān)資源