教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 范文大全 > 公文资料 >

操作系统实验一选择一个调度算法,实现处理器调度。

来源:网络收集 时间:2026-08-29
导读: 选择一个调度算法,实现处理器调度。 操作系统实验一报告 一.实验内容 选择一个调度算法,实现处理器调度。 二.实验目的 在采用多道程序设计的系统中,往往有若干个进程同时处于就绪状态。当就绪状态进程个数大于处理器数时,就必须依照某种策略来决定哪些

选择一个调度算法,实现处理器调度。

操作系统实验一报告

一.实验内容

选择一个调度算法,实现处理器调度。

二.实验目的

在采用多道程序设计的系统中,往往有若干个进程同时处于就绪状态。当就绪状态进程个数大于处理器数时,就必须依照某种策略来决定哪些进程优先占用处理器。本实验模拟在单处理器情况下处理器调度,帮助学生加深了解处理器调度的工作。

三.实验要求

设计一个按优先数调度算法实现处理器调度的进程。

上面的过程只给出了 那个寻找以及排序的大体过程,具体的过程太多画不下。。

选择一个调度算法,实现处理器调度。

四.实验程序

这个实验的程序使用的visual studio 2008 的c++ win控制台写的,所以可能老师的电脑里面。。。。。。。。。 我把程序结果贴在后面,还有第二题我也做了 ,但只要求写一个,那么。。

// 操作系统实验.cpp : 定义控制台应用程序的入口点。

//

#include "stdafx.h"

#include<iostream>

#include<string>

using namespace std;

static int num=0;

class proc

{

private: string procname;

proc * next;

int time;

int priority;

char state;

public:

proc(){

proc*next=new proc();

{

}

~proc(){}

void setnext(proc * n)

{

next=n;

}

void setprocname(string s){procname=s;}

void settime(int t){time=t;} } proc(string pr,proc * ne,int ti,int pri,char st):procname(pr),next(ne),time(ti),priority(pri),state(st)

选择一个调度算法,实现处理器调度。

void setpriority(int s){priority=s;}

void setstate(char s){state=s;}

proc * getnext(){return next;}

string getprocname(){return procname;}

int gettime(){return time;}

int getpriority(){return priority;}

char getstate(){return state;}

};

class dui

{

private:

proc * first;

public:

dui(){first=new proc();}

dui(proc*f){ first=f;} int getfirst_time(){return first->gettime();} void show(proc*p) { cout<<"名字 "<<"下个节点的名字"<<" "<<"时间 "<<"优先级 "<<"状态"<<endl; while(p) { cout<<p->getprocname ()<<" "<<((p->getnext()!=NULL)?p->getnext

()->getprocname ():"NU")<<" "<<p->gettime ()<<" "<<p->getpriority()<<" "<<((p->gettime ()!=0)?p->getstate():'E')<<endl;

} { proc*pp=first; show(first); while( first->getnext ()!=NULL) { } cout<<"..............................................................."<<endl; p=p->getnext (); void process1()

选择一个调度算法,实现处理器调度。

int a,b; a=pp->getpriority()-1; b=pp->gettime()-1; pp->setpriority(a); pp->settime(b); if(b==0) { } int prio1,prio2; prio2=first->getnext ()->getpriority(); prio1=pp->getpriority(); show(pp); pp =first=first->getnext (); continue; if(prio1>=prio2) {show(pp); } else { } if(prio1>=prio2) { pp->setnext (first->getnext ()); first->setnext (pp); show(pp_next); first=first->getnext (); if(first->getnext ()==NULL) { } else prio2=first->getnext ()->getpriority(); first->setnext (pp); pp->setnext (NULL); break; { while(prio1<prio2)

选择一个调度算法,实现处理器调度。

if(pp->getnext ()==NULL) {show(pp_next); } pp=pp_next;first=pp; }

}

};

int main()

{

proc * A=new proc("p1",NULL,2,1,'R'); } if(first->getnext ()==NULL) while(first->gettime()>0) {int t=first->gettime()-1; first->settime(t);show(first); cout<<"五"; }

proc * B=new proc("p2",NULL,3,5,'R');

proc * C=new proc("p3",NULL,1,3,'R');

proc * D=new proc("p4",NULL,2,4,'R');

proc * E=new proc("p5",NULL,4,2,'R');

B->setnext (D);

D->setnext (C);

C->setnext (E);

E->setnext (A);

dui aaa(B);

}

五.实验结果

//aaa.setfirst (B); aaa.process1 (); cin.get(); return 0 ;

选择一个调度算法,实现处理器调度。

选择一个调度算法,实现处理器调度。

六.实验总结

这个说来惭愧啊 ,因为自己的这个程序早就做好了,就是对进程啊什么的还不是很了解,因为自己不是学习认真的那一种,这个老师的那些问题把我给郁闷了好多天啊!悲剧!

以后还是要好好学习,课后不能再玩得那么狠了!

通过这个程序,我体会到了些程序前先把图给画出来是都么好的习惯啊!以后要多多用! 还有我的电脑因为不知道什么病毒,c盘重还原了一下,原来在桌面的那个报告比这个更详细,这次因为不能上传加上自己没有保存就丢失了那个报告,临时写的这个希望老师不要怪我!!

最后希望老师弄一下,最起码我们可以在机房里上传到ftp中!!!

…… 此处隐藏:1098字,全部文档内容请下载后查看。喜欢就下载吧 ……
操作系统实验一选择一个调度算法,实现处理器调度。.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/fanwen/2178558.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)