操作系统课程设计报告.docx

上传人:b****9 文档编号:30828783 上传时间:2024-01-30 格式:DOCX 页数:50 大小:357.04KB
下载 相关 举报
操作系统课程设计报告.docx_第1页
第1页 / 共50页
操作系统课程设计报告.docx_第2页
第2页 / 共50页
操作系统课程设计报告.docx_第3页
第3页 / 共50页
操作系统课程设计报告.docx_第4页
第4页 / 共50页
操作系统课程设计报告.docx_第5页
第5页 / 共50页
点击查看更多>>
下载资源
资源描述

操作系统课程设计报告.docx

《操作系统课程设计报告.docx》由会员分享,可在线阅读,更多相关《操作系统课程设计报告.docx(50页珍藏版)》请在冰豆网上搜索。

操作系统课程设计报告.docx

操作系统课程设计报告

 

操作系统课程设计报告

 

学期2013-2014学年第二学期

学院计算机科学与技术学院

学号1213022034

姓名高丹凤

 

课设要求:

操作系统课程设计内容:

完成:

1、进程/作业调度算法至少3个

2、页面置换算法至少3个

3、驱动调度算法至少3个

4、银行家算法

做一个系统界面,将这些算法全部纳入界面,在界面中选择相应算法,则开始相应算法的演示。

操作系统:

win7

语言:

C#

程序代码:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.IO;

namespaceMyApp

{

publicpartialclassForm1:

Form

{

publicForm1()

{

InitializeComponent();

}

privatevoidradioButton1_CheckedChanged(objectsender,EventArgse)

{

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

if(radioButton1.Checked==true)

{

Form2f=newForm2();

f.Show();

this.Show();

}

elseif(radioButton2.Checked==true)

{

Form3f=newForm3();

f.Show();

this.Show();

}

elseif(radioButton3.Checked==true)

{

Form4f=newForm4();

f.Show();

this.Show();

}

elseif(radioButton4.Checked==true)

{

Form5f=newForm5();

f.Show();

this.Show();

}

}

}

}

 

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

namespaceMyApp

{

publicpartialclassForm2:

Form

{

publicForm2()

{

InitializeComponent();

}

privatevoidForm2_Load(objectsender,EventArgse)

{

}

classzuoye{

 

publicdoubles;//输?

入?

时骸?

间?

publicdoublej;//执′行D时骸?

间?

publicdoublek;//开a始?

时骸?

间?

publicdoublew;//完?

成é时骸?

间?

publicdoublez;//周ü转羇时骸?

间?

publicdoubled;//带?

权ā?

周ü转羇时骸?

间?

};

inti=3;

doublem,n;

//先è来ぁ?

先è服务?

privatevoidbutton2_Click(objectsender,EventArgse)

{

zuoye[]a=newzuoye[3];

doubleT=0;

doubleW=0;

s1.Clear();

s2.Clear();

intj=0;

for(inth=0;h<3;h++)

a[h]=newzuoye();

a[0].s=Convert.ToDouble(t1.Text);

a[0].j=Convert.ToDouble(t2.Text);

a[1].s=Convert.ToDouble(m1.Text);

a[1].j=Convert.ToDouble(m2.Text);

a[2].s=Convert.ToDouble(n1.Text);

a[2].j=Convert.ToDouble(n2.Text);

a[0].k=a[0].s;

a[0].w=a[0].k+a[0].j;

a[0].z=a[0].w-a[0].s;

a[0].d=a[0].z/a[0].j;

for(j=1;j

{

a[j].k=a[j-1].w;//开a始?

时骸?

间?

a[j].w=a[j].k+a[j].j;//完?

成é时骸?

间?

a[j].z=a[j].w-a[j].s;//周ü转羇时骸?

间?

a[j].d=a[j].z/a[j].j;//带?

权ā?

周ü转羇时骸?

间?

T+=a[j].z;

W+=a[j].d;

}

m=T/i;

n=W/i;

s1.Text=Convert.ToString(m);

s2.Text=Convert.ToString(n);

}

 

//最?

短ì作痢?

业唉?

privatevoidbutton1_Click(objectsender,EventArgse)

{

zuoye[]a=newzuoye[3];

doubleT=0;

doubleW=0;

for(inth=0;h<3;h++)

a[h]=newzuoye();

a[0].s=Convert.ToDouble(t1.Text);

a[0].j=Convert.ToDouble(t2.Text);

a[1].s=Convert.ToDouble(m1.Text);

a[1].j=Convert.ToDouble(m2.Text);

a[2].s=Convert.ToDouble(n1.Text);

a[2].j=Convert.ToDouble(n2.Text);

intj=0,k=0,c=0,b=0;

zuoyet;

a[0].k=a[0].s;

a[0].w=a[0].k+a[0].j;

a[0].z=a[0].w-a[0].s;

a[0].d=a[0].z/a[0].j;

T=a[0].z;

W=a[0].d;

for(j=1;j

{

k=j;

while(a[k].s<=a[j-1].w&&k

处鋦于?

准?

备?

状痢?

态?

的?

作痢?

业唉?

{

k++;

}

for(c=j;c

法ぁ?

进?

行D排?

序ò

{

for(b=c+1;b

{

if(a[c].j>a[b].j)

{

t=a[c];a[c]=a[b];a[b]=t;

}

}

}

a[j].k=a[j-1].w;

a[j].w=a[j].k+a[j].j;

a[j].z=a[j].w-a[j].s;

a[j].d=a[j].z/a[j].j;

T+=a[j].z;

W+=a[j].d;

}

m=T/i;

n=W/i;

s1.Text=Convert.ToString(m);

s2.Text=Convert.ToString(n);

}

 

//响ì应畖比括?

privatevoidbutton3_Click(objectsender,EventArgse)

{

zuoye[]a=newzuoye[3];

doubleT=0;

doubleW=0;

for(inth=0;h<3;h++)

a[h]=newzuoye();

a[0].s=Convert.ToDouble(t1.Text);

a[0].j=Convert.ToDouble(t2.Text);

a[1].s=Convert.ToDouble(m1.Text);

a[1].j=Convert.ToDouble(m2.Text);

a[2].s=Convert.ToDouble(n1.Text);

a[2].j=Convert.ToDouble(n2.Text);

double[]s=newdouble[10];

double[]z=newdouble[10];

for(i=0;i

{

s[0]=0;

s[i+1]=s[i]+a[i].j;

z[i+1]=(s[i+1]-a[i].s)/a[i].j;

T=T+s[i+1]-a[i].s;

W=W+z[i+1];

}

m=T*1.0/3;

n=W*1.0/3;

s1.Text=Convert.ToString(m);

s2.Text=Convert.ToString(n);

}

privatevoidbutton4_Click(objectsender,EventArgse)

{

s1.Clear();

s2.Clear();

}

}

}

 

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

namespaceMyApp

{

publicpartialclassForm3:

Form

{

publicForm3()

{

InitializeComponent();

}

 

//FIFO

privatevoidbutton1_Click(objectsender,EventArgse)

{

doubles;

inti,j,k;

intM=Convert.ToInt16(s1.Text);//内ú存?

块é数簓

intN=12;

int[]a=newint[30];//M的?

最?

大洙?

值μ

int[]b=newint[30];

b[0]=Convert.ToInt16(t1.Text);

b[1]=Convert.ToInt16(t2.Text);

b[2]=Convert.ToInt16(t3.Text);

b[3]=Convert.ToInt16(t4.Text);

b[4]=Convert.ToInt16(t5.Text);

b[5]=Convert.ToInt16(t6.Text);

b[6]=Convert.ToInt16(t7.Text);

b[7]=Convert.ToInt16(t8.Text);

b[8]=Convert.ToInt16(t9.Text);

b[9]=Convert.ToInt16(t10.Text);

b[10]=Convert.ToInt16(t11.Text);

b[11]=Convert.ToInt16(t12.Text);

 

int[]c=newint[20];

for(i=0;i<20;i++)

c[i]=0;

 

for(i=0;i

{

a[i]=b[i];

}

k=M;

for(j=M;j<12;j++)

{

for(i=0;i

if(b[j]==a[i])

{

c[j]=1;

break;

}

if(c[j]==0)

{

a[k%N]=b[j];

k++;

}

}

s=Convert.ToDouble(k*1.0/12);

s2.Text=Convert.ToString(k);//缺ā?

页?

次?

数簓

s3.Text=Convert.ToString(s);//缺ā?

页?

率ê

}

 

//LRU

privatevoidbutton2_Click(objectsender,EventArgse)

{

inti,j;

intM=Convert.ToInt16(s1.Text);//M的?

最?

大洙?

值μ10

intN=12;

int[][]c=newint[20][];

for(i=0;i<10;i++)

{

c[i]=newint[30];

}

int[]a=newint[30];//M的?

最?

大洙?

值μ

page[]b=newpage[30];//M值μ

a[0]=Convert.ToInt16(t1.Text);

a[1]=Convert.ToInt16(t2.Text);

a[2]=Convert.ToInt16(t3.Text);

a[3]=Convert.ToInt16(t4.Text);

a[4]=Convert.ToInt16(t5.Text);

a[5]=Convert.ToInt16(t6.Text);

a[6]=Convert.ToInt16(t7.Text);

a[7]=Convert.ToInt16(t8.Text);

a[8]=Convert.ToInt16(t9.Text);

a[9]=Convert.ToInt16(t10.Text);

a[10]=Convert.ToInt16(t11.Text);

a[11]=Convert.ToInt16(t12.Text);

commomsw=newcommom();

sw.Commom(M);

sw.K=-1;

sw.Init(b,c);

for(i=0;i

{

sw.Lru(a[i],b);

c[0][i]=a[i];/*记?

录?

当獭?

前°的?

内ú存?

单蹋?

元a中D的?

页?

面?

*/

for(j=0;j

{

c[j][i]=b[j].num;

}

/*结á果?

输?

出?

*/

doubleT=(sw.K+1)*1.0/N;

s2.Text=Convert.ToString(sw.K*1.0+1);

s3.Text=Convert.ToString(T);

 

}

}

 

//函ˉ数簓方?

法ぁ?

体?

structpage

{

publicintnum;/*记?

录?

页?

面?

号?

*/

publicinttime;/*记?

录?

调獭?

入?

内ú存?

时骸?

间?

*/

};

classcommom

{

publicintM=0;//内ú存?

块é数簓

intN=20;//页?

面?

号?

数簓

publicintK;

publicvoidCommom(intM)

{

this.M=M;

}

int[]queue=newint[100];/*记?

录?

调獭?

入?

队ó列*/

/*初?

始?

化ˉ内ú存?

单蹋?

元a、¢缓o冲?

区?

*/

publicvoidInit(page[]b,int[][]c)

{

inti,j;

for(i=0;i

{

b[i].num=-1;

b[i].time=N-i-1;

}

for(i=0;i

for(j=0;j

c[i][j]=-1;

}

/*取?

得?

在ú内ú存?

中D停?

留?

最?

久?

的?

页?

面?

默?

认?

状痢?

态?

下?

为a最?

早?

调獭?

入?

的?

页?

面?

*/

publicintGetMax(page[]b)

{

inti;

intmax=-1;

inttag=0;

for(i=0;i

{

if(b[i].time>max)

{

max=b[i].time;

tag=i;

}

}

returntag;

}

/*判D断?

页?

面?

是?

否?

已?

在ú内ú存?

中D*/

publicintEquation(intfold,page[]b)

{

inti;

for(i=0;i

{

if(fold==b[i].num)

returni;

}

return-1;

}

/*LRU核?

心?

部?

分?

*/

publicvoidLru(intfold,page[]b)

{

inti;

intval;

val=Equation(fold,b);

if(val>=0)

{

b[val].time=0;

for(i=0;i

if(i!

=val)

b[i].time++;

}

else

{

queue[++K]=fold;/*记?

录?

调獭?

入?

页?

面?

*/

val=GetMax(b);

b[val].num=fold;

b[val].time=0;

for(i=0;i

if(i!

=val)

b[i].time++;

}

}

}

internalvoidInit(int[]b,int[][]c)

{

thrownewNotImplementedException();

}

internalvoidLru(intp,int[]b)

{

thrownewNotImplementedException();

}

 

//OPT

privatevoidbutton3_Click(objectsender,EventArgse)

{

node2[]b=newnode2[20];

node1[]pag=newnode1[20];

intchose;

intm,n;

m=Convert.ToInt16(s1.Text);//内ú存?

块é数簓

n=12;

pag[0].num=Convert.ToInt16(t1.Text);

pag[1].num=Convert.ToInt16(t2.Text);

pag[2].num=Convert.ToInt16(t3.Text);

pag[3].num=Convert.ToInt16(t4.Text);

pag[4].num=Convert.ToInt16(t5.Text);

pag[5].num=Convert.ToInt16(t6.Text);

pag[6].num=Convert.ToInt16(t7.Text);

pag[7].num=Convert.ToInt16(t8.Text);

pag[8].num=Convert.ToInt16(t9.Text);

pag[9].num=Convert.ToInt16(t10.Text);

pag[10].num=Convert.ToInt16(t11.Text);

pag[11].num=Convert.ToInt16(t12.Text);

copsw=newcop();

chose=sw.display(b,m,pag,n);

if(chose==3)

{

sw.OPT(b,m,pag,n);

}

s2.Text=Convert.ToString(sw.x);

s3.Text=Convert.ToString(sw.x*1.0/12);

}

}

//OPT方?

法ぁ?

体?

 

structnode1

{

publicintnum;

publicintage;

publicintstate;

publicintblocknum;

}//paage

structnode2

{

publicintnum;

publicintstate;

publicintpagenum;

publicintage;

}//block

 

classcop

{

publicintx;//缺ā?

页?

总哩?

次?

数簓

publicvoidOPT(node2[]b,intn,node1[]p,intm)/*最?

优?

页?

面?

置?

换?

算?

法ぁ?

*/

{

inti,j,k,mm,mn,flag=0;

intmaxage=-1,c=0;

for(j=0;j

{

for(mm=0;mm

{

if(b[mm].pagenum==p[j].num)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 经济学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1