操作系统实验一选择一个调度算法,实现处理器调度。
选择一个调度算法,实现处理器调度。
操作系统实验一报告
一.实验内容
选择一个调度算法,实现处理器调度。
二.实验目的
在采用多道程序设计的系统中,往往有若干个进程同时处于就绪状态。当就绪状态进程个数大于处理器数时,就必须依照某种策略来决定哪些进程优先占用处理器。本实验模拟在单处理器情况下处理器调度,帮助学生加深了解处理器调度的工作。
三.实验要求
设计一个按优先数调度算法实现处理器调度的进程。
上面的过程只给出了 那个寻找以及排序的大体过程,具体的过程太多画不下。。
选择一个调度算法,实现处理器调度。
四.实验程序
这个实验的程序使用的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字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [公文资料]市场营销专员岗位职责
- [公文资料]综合部经理岗位职责
- [公文资料]会计助理岗位职责
- [公文资料]林业站站长职责
- [公文资料]菜品研发部岗位职责
- [公文资料]街道综治办工作职责
- [公文资料]酒店前台的工作职责
- [公文资料]销售部经理岗位职责
- [公文资料]工程部副经理岗位职责
- [公文资料]手术室护士工作职责
- [公文资料]银行客户经理职责
- [公文资料]汽车4s店市场专员职责
- [公文资料]服装店长工作职责
- [公文资料]采购总监岗位职责
- [公文资料]大学行政秘书工作职责
- [公文资料]学校财务人员岗位职责
- [公文资料]财务统计员岗位职责
- [公文资料]物业工程主管工作职责
- [公文资料]公司后勤工作职责
- [公文资料]采矿工程师岗位职责
- 门面出租合同样板(门面出租的合同)
- 自用房屋租赁合同 自住房租房合同(汇总
- 最新酒店劳动合同管理制度(11篇)(酒店
- 2025年无产权车库买卖合同实用(14篇)(
- 建筑工程农民工劳动合同十五篇(通用)(
- 最新深圳标准劳动合同 深圳劳动合同如
- 解除劳动合同通知书(实用6篇)(解除劳动
- 2025年二手房屋买卖合同范围精选(二十
- 最新融资贷款居间合同大全(22篇)(融资
- 2025年个人二手房屋买卖合同协议书四篇
- 2025年果树苗木买卖合约书 签订果树苗
- 广东省劳动合同书填写(21篇)(广东省劳
- 最新餐饮行业没有劳动合同 劳动法餐饮
- 农村土地买卖合同(汇总21篇)(农村土地
- 最新房屋转租合同模版21篇(通用)(标准
- 2025年进口合同号查询五篇(大全)(进口
- 农村建房包工包料合同(通用8篇)(农村建
- 2025年安装监控合同协议书(15篇)(2025
- 2025年企业租赁经营合同(模板9篇)(2025
- 最新郊区土地租赁合同(优质23篇)(最新




