《操作系统课程设计》报告范本

上传人:新** 文档编号:507223032 上传时间:2022-10-08 格式:DOC 页数:12 大小:311.50KB
返回 下载 相关 举报
《操作系统课程设计》报告范本_第1页
第1页 / 共12页
《操作系统课程设计》报告范本_第2页
第2页 / 共12页
《操作系统课程设计》报告范本_第3页
第3页 / 共12页
《操作系统课程设计》报告范本_第4页
第4页 / 共12页
《操作系统课程设计》报告范本_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《《操作系统课程设计》报告范本》由会员分享,可在线阅读,更多相关《《操作系统课程设计》报告范本(12页珍藏版)》请在金锄头文库上搜索。

1、操作系统课程设计报告学号:姓 名:班 级:指导教师:报告日期:、课设目的通过对操作系统课程的学习,熟悉进程的概念、进程的管理与存储、进程的调度,通 过实践深入理解进程的调度算法。二、课设任务要求编写一个程序,可以创建若干个虚拟进程,并对若干个虚拟进程进行调度,调度 策略为时间片轮转法,主要任务包括:进程的个数,进程的内容(即进程的功能序列)来源于一个进程序列描述文件,另 外调度运行结果输出到一个运行日志文件;设计PCB适用于时间片轮转法;建立进程队列;实现时间片轮转调度算法,尽量可视化的展示调度的动态过程。总结程序设计的开发过程:需求分析、系统设计、系统实现及文档的收集和整理。三、实验方法与设

2、计分析每个进程有一个进程控制块(PCB)表示。进程控制块可以包含如下信息:进程名、优先数、到达时间、需要运行时间、已用CPU时间、进程状态等等。进程的优先数及需要的运行时间可以事先人为地指定(也可以由随机数产生)。进程的到 达时间为输入进程的时间。进程的运行时间以时间片为单位进行计算。每个进程的状态可以是就绪W( Wait)、运行R( Run)、或完成F( Fin ish )三种状态之一。就绪进程获得 CPU后都只能运行一个时间片。用已占用CPU时间加1来表示。如果运行一个时间片后,进程的已占用 CPU时间已达到所需要的运行时间 ,则撤消该进程, 如果运行一个时间片后进程的已占用CPU时间还未

3、达所需要的运行时间,也就是进程还需要继续运行,此时应将进程的优先数减1 (即降低一级),然后把它插入就绪队列等待CPU每进行一次调度程序都打印一次运行进程、就绪队列、以及各个进程的PCB,以便进行检查。重复以上过程,直到所要进程都完成为止四、程序流程图五、程序源代码#in cludestdafx.h#in clude#in clude#in clude#in clude#in clude#in cludeusing n amespace std;ofstream myfile( bb.txt,ios:app|ios:tr un c);typedef struct n odechar name1

4、0; /* 进程名 */int round;/*进程分配的时间片*/int cputime;/*进程消耗的CUP寸间*/int needtime;/*进程需要的CUP寸间*/int count;/* 进程运行寸间 */char state;/* 进程的状态: R: 运行 ,W :等待 ,F :结束 */struct node *next; /* 指向下一个进程的指针 */PCB;PCB *finish,*ready,*tail,*run;/* 指向三个队列的队首的指针, tail 为就绪队列的队尾指针 */ int N; /* 定义进程的数目 */void firstin( void )if

5、(ready!=NULL)run=ready;ready=ready-next; run-state= R ; run-next=NULL;elserun=NULL;void prt1( char a)void prt2( char a,PCB *p) coutname stateendl;myfilenamecputimeneedtimecountround;myfilecputime;myfileneedtimemyfilecount myfilestateendl;myfileroundcout name cputime needtime count round state endl;m

6、yfile name ;myfile cputime ;myfile needtime ;myfile count ;myfile round ;myfile state next;p=finish;while (p!=NULL)prt2(algo,p); p=p-next;getchar();void insert(PCB *q)tail-next=q;tail=q;q-next=NULL;void rcreate_task( char algo)PCB *p;int n,time;char na10;ready=NULL;finish=NULL;run=NULL;coutN;for (n=

7、0;nN;n+)endl;endl;p=(PCB*)malloc( sizeof (PCB); coutna;couttime;strcpy(p-name,na); p-cputime=0;p-needtime=time; p-count=0;p-state= W ;p-round=2;if (ready!=NULL) insert(p);elsep-next=ready;ready=p;tail=p;run=ready;ready=ready-next;run-state= R ;cout 创建成功。 count=run-round)run-count=0;if (ready!=NULL)r

8、un-state= W ;insert(run);firstin();prt(algo);void roundrun( char algo)while (run!=NULL)run-cputime=run-cputime+1; run-needtime=run-needtime-1; run-count=run-count+1;if (run-needtime=0)run-next=finish;finish=run;run-state= F ;run=NULL;if (ready!=NULL)firstin();elseif (run-count=run-round)run-count=0;

9、if (ready!=NULL)run-state= W ;insert(run);firstin();prt(algo); void caidan()cout *主页 *endl;cout *1.I创建若干进程 *endl;cout *2.C进程进行查看 *endl;cout *3.O进程进行调度 *endl;cout *4.H结束 *algo;if (algo= i |algo= I )rcreate_task(algo);else if (algo= c |algo= C )chakan(algo);else if (algo= o |algo= O )roundrun(algo);el

10、se if (algo二二h |algo二二H)goto loop2;goto loopl;loop2:myfile.close();return 0;六、运行结果Enteit inemaneEntert ine-MrMrMKXJCKXMKICXKMi Mi Cneedt ineroundpane2X J X X X X H K貝貝貝needt inecountnameGput inecountnameneedtinaneround2io tin d22pound2count2*1needt irtecpat ine 0 0cpat ime 0请输入进程数目N 2 EnterM:*f JC JK JK 鼻 K JM Mi UK Wm it it it 坯 it itfj mHHi*住it 童 it it nt 負負負 負 jc w: m: xiocpl | 建!g干进 程 *44*4 ifei 结束创建成功“杯杠杠杠圭贡 ;豪耗舞轟舞乱群粧廉帯帯诞廉声莆声料科Mg . Q 彳井秤 1井 fT 住看科舞舞耗耗KKKKKKKKKtf/M科料 -3.0逬i进和*4.H 结東count0_0贞 K X K JU K XJO X X XX XJC X X K X XX KX JOC 仓J#旱fifsfcw结束

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号