国产精品婷婷久久久久久,国产精品美女久久久浪潮av,草草国产,人妻精品久久无码专区精东影业

操作系統(tǒng)實(shí)驗(yàn)報(bào)告四模擬電梯調(diào)度算法,對(duì)磁盤進(jìn)行移臂和旋轉(zhuǎn)調(diào)度.doc

約7頁DOC格式手機(jī)打開展開

操作系統(tǒng)實(shí)驗(yàn)報(bào)告四模擬電梯調(diào)度算法,對(duì)磁盤進(jìn)行移臂和旋轉(zhuǎn)調(diào)度,操作系統(tǒng)實(shí)驗(yàn)報(bào)告四全文7頁708字圖文并茂時(shí)間:2005.5.15實(shí)驗(yàn)題目:模擬電梯調(diào)度算法,對(duì)磁盤進(jìn)行移臂和旋轉(zhuǎn)調(diào)度年級(jí):2002級(jí) 班級(jí):計(jì)算機(jī)(5)班姓名:學(xué)號(hào):任課教師:實(shí)驗(yàn)要求:模擬電梯調(diào)度算法,實(shí)現(xiàn)對(duì)磁盤的驅(qū)動(dòng)調(diào)度, 磁盤是一種高速、大容量、旋轉(zhuǎn)型、可直接存取的存儲(chǔ)設(shè)備。它作為計(jì)算機(jī)系統(tǒng)的輔助存儲(chǔ)器,擔(dān)負(fù)著...
編號(hào):10-32970大小:54.50K
分類: 論文>數(shù)學(xué)/物理論文

內(nèi)容介紹

此文檔由會(huì)員 黃藥師 發(fā)布

操作系統(tǒng)實(shí)驗(yàn)報(bào)告四
全文7頁708字 圖文并茂 時(shí)間:2005.5.15
實(shí)驗(yàn)題目:模擬電梯調(diào)度算法,對(duì)磁盤進(jìn)行移臂和旋轉(zhuǎn)調(diào)度 年級(jí):2002級(jí) 班級(jí):計(jì)算機(jī)(5)班
姓名: 學(xué)號(hào): 任課教師:
實(shí)驗(yàn)要求:
模擬電梯調(diào)度算法,實(shí)現(xiàn)對(duì)磁盤的驅(qū)動(dòng)調(diào)度, 磁盤是一種高速、大容量、旋轉(zhuǎn)型、可直接存取的存儲(chǔ)設(shè)備。它作為計(jì)算機(jī)系統(tǒng)的輔助存儲(chǔ)器,擔(dān)負(fù)著繁重的輸入輸出任務(wù)、在多道程序設(shè)計(jì)系統(tǒng)中,往往同時(shí)會(huì)有若干個(gè)要求訪問磁盤的輸入輸出請(qǐng)求等待處理。系統(tǒng)可采用一種策略,盡可能按最佳次序執(zhí)行要求訪問磁盤的諸輸入輸出請(qǐng)求。這就叫驅(qū)動(dòng)調(diào)度,使用的算法稱為驅(qū)動(dòng)調(diào)度算法。驅(qū)動(dòng)調(diào)度能降低為若干個(gè)輸入輸出請(qǐng)求服務(wù)所需的總時(shí)間,從而提高系統(tǒng)效率。本實(shí)驗(yàn)要求學(xué)生模擬設(shè)計(jì)一個(gè)驅(qū)動(dòng)調(diào)度程序,觀察驅(qū)動(dòng)調(diào)度程序的動(dòng)態(tài)運(yùn)行過程。通過實(shí)驗(yàn)使學(xué)生理解和掌握驅(qū)動(dòng)調(diào)度的職能。
解題思路(流程圖):


























實(shí)驗(yàn)結(jié)果(部分源碼):
#include
#include
#include
#define null 0
#define len sizeof(struct cidaohao)
struct cidaohao
{
struct cidaohao *pre;
int num;
struct cidaohao *next;
};
FCFS(array)
int array[50];
{int i,j,sum=0;
printf("nFCFS : ");
for(i=1;array[i]!=-1;i++)
{
printf(" %d ",array[i]);
}
i=0;
for(i=0,j=1;array[j]!=-1;i++,j++)
{
if(array[i]>array[j]) sum+=(array[i]-array[j]);
else sum+=(array[j]-array[i]);
}
return(sum);
}
SSTF(head,now)
struct cidaohao *head;
int now;
{struct cidaohao *p,*lp,*rp;
int sum=0,front,behind;
p=head;
printf("nSSTF :");
while(p->num!=now) p=p->next;/* */
lp=p->pre;
rp=p->next;
do
{
if(p->next!=null&&p->pre!=null)
{ front=p->num-lp->num;
behind=rp->num-p->num;
if(front>=behind)
{
sum+=behind;
p=rp;
printf(" %d ",p->num);
rp=p->next;
}
else
{
sum+=front;
p=lp;
printf(" %d ",p->num);
lp=p->pre;
}
}
else
{
if(p->next==null)
{ while(lp->num!=0)
{
sum+=p->num-lp->num;
p=lp;
printf(" %d ",p->num);
lp=p->pre;
}
return(sum);
}
if(p->pre==null)
{
while(rp->num!=0)
{
sum+=rp->num-p->num;
p=rp;
printf(" %d ",p->num);
rp=p->next;
}
return(sum);
}
}
}while(p->next!=null||p->pre!=null);
}
SCAN(head,n,m)
struct cidaohao *head;
int n,m;
{struct cidaohao *p,*pp;
int sum=0;
printf("nSCAN : ");
p=head;
while(p->num!=m) p=p->next;/* */
pp=p;
if(n {while(pp->next!=null)
{
sum+=pp->next->num-pp->num;
pp=pp->next;
printf(" %d ",pp->num);
}
sum+=pp->num-p->pre->num;
pp=p->pre;
if(pp->num==0) return(sum);
else
{while(pp->pre!=null)
{
printf(" %d ",pp->num);
sum+=pp->num-pp->pre->num;
pp=pp->pre;
}
printf(" %d ",pp->num);
return(sum);
}
}
else
{
while(pp->pre!=null)
{
sum+=pp->num-pp->pre->num;
pp=pp->pre;
printf(" %d ",pp->num);
}
sum+=p->next->num-pp->num;
pp=p->next;
if(pp->num==0) return(sum);
else
{while(pp->next!=null)
{
printf(" %d ",pp->num);
sum+=pp->next->num-pp->num;
pp=pp->next;
}
printf(" %d ",pp->num);
return(sum);
}
}
}
main()
{
FILE *fp;
char pt;
char str[10];
int cidao[100],i,j=1,count1=0,count2=0,count3=0,last,space=0;
struct cidaohao *p1,*p2,*new,*head;/* */
struct cidaohao *p,*lp,*rp;
for(i=0;i<50;i++) cidao[i]=-1;
i=0;
fp=fopen("cipan.txt","r+");/* */
if(fp==NULL)
{
printf("Cann't open this file ");
exit(0);
}
printf("nPlease input cidaohao now : ");
scanf("%d",&cidao[0]);
while((pt=fgetc(fp))!=EOF)/* */
{
if(pt>='0'&&pt<='9')
{
str[i]=pt;i++;
space=0;
}
else
{
if(pt==' '||pt=='n')
{if(space==1) break;
else
{str[i]='0';
cidao[j]=atoi(str);
if(pt=='n') break;
else
{
space=1;
j++;
i=0;
}
}
}
}
}/* */
if(pt==EOF) {str[i]='0';cidao[j]=atoi(str);}
fclose(fp);
i=0;
count1=FCFS(cidao);/* */
printf("nThe Total : %d n",count1);
p1=p2=head=(struct cidaohao* )malloc(len);/* */
p1->pre=null;
p1->num=cidao[0];
p1->next=null;
i=1;
while(cidao[i]!=-1)
{ if(cidao[i]num)/* */
{
p1=(struct cidaohao *)malloc(len);
p1->next=head;
p1->pre=null;
p1->num=cidao[i];
head->pre=p1;
head=p1;
}
else
{
while(p1->next!=null&&p1->num<=cidao[i])/* */
{ p2=p1;
p1=p1->next;
}
if (p1->num>cidao[i])/* */
{
new=(struct cidaohao*)malloc(len);
new->num=cidao[i];
new->next=p1;
new->pre=p2;
p1->pre=new;
p2->next=new;
}
else
{/* */
new=(struct cidaohao*)malloc(len);
new->num=cidao[i];
new->next=null;
new->pre=p1;
p1->next=new;
}
p1=head;/* */
}
i++;/* */
}
count2=SSTF(head,cidao[0]);
printf("nThe Total : %d ",count2);
printf("nnPleast input last cipanhao : ");
scanf("%d",&last);
count3=SCAN(head,last,cidao[0]);
printf("nThe Total : %d n",count3);
}