• 管理员
    了解作者
  • C++
    开发工具
  • 54KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 16
    下载次数
  • 2007-05-05 12:41
    上传日期
C++编程实例Round Robin Scheduling Task
RoundRobinSchedulingTask.rar
  • 实例97
  • RRS.CPP
    5.6KB
  • RRS.DSK
    2.4KB
  • RRS.PRJ
    4.2KB
  • EGAVGA.BGI
    5.4KB
  • RRS.EXE
    59.6KB
  • RRS.OBJ
    12.9KB
  • 97.BMP
    458.4KB
  • RR.H
    2.3KB
  • www.pudn.com.txt
    218B
内容介绍
//THE PROGRAM IS TO TEST THE OPERATING SYSTEM'S "ROUND-ROBIN SCHEDULING". //FILE RRS.CPP #include <stdio.h> #include <conio.h> #include <string.h> #include <stdlib.h> #include <graphics.h> #include "Rr.h" #define Count 5 float TqTs[Count]; int Quantum=0,Finish[Count]; int Ts[Count],ArriveTime[Count],EndTime[Count],Tq[Count]; void Kernel(void); void Result(void); void Version(void); void InitGrid(void); int IF_Finish(void); void InitGraph(void); void InitRecord(void); void InitProcess(void); Node Table[50]; Grid Record,Graph; int main(void) { InitProcess(); getch(); InitGraph(); InitRecord(); InitGrid(); Kernel(); Result(); Version(); getch(); closegraph(); return 0; } void InitGraph(void) { int Gdriver=DETECT,Gmode,Errorcode; initgraph(&Gdriver,&Gmode,"D:\\Tools\\Tc3.0\\Bgi"); Errorcode=graphresult(); if (Errorcode!=grOk) { printf("Graphics Error: %s\n",grapherrormsg(Errorcode)); printf("Press any key to exit:"); getch(); exit(1); } } void InitProcess(void) { int i; window(1,1,80,25); textbackground(1); textcolor(14); clrscr(); printf("\n ---------- The Round Robin Scheduling ---------\n"); printf("\n***** Input The Quantum Time Of The Process : "); scanf("%d",&Quantum); for (i=0;i<Count;i++) { printf("\n----- Input The Arrive Time Of The Process %d : ",i+1); scanf("%d",&ArriveTime[i]); printf("\n***** Input The Service Time Of The Process %d : ",i+1); scanf("%d",&Ts[i]); } } void InitRecord(void) { int number=0,circle,i; for (i=0;i<Count+1;i++) { for (circle=0;circle<Count+1;circle++) { Record.NewRectangle(number,15+circle*100,20+i*20, circle*100+115,20+((i+1)*20)); number=number+1; } } setcolor(14); Record.GetRectangle(1)->Outtextxy("ArriveTime"); Record.GetRectangle(2)->Outtextxy(" Ts "); Record.GetRectangle(3)->Outtextxy("FinishTime"); Record.GetRectangle(4)->Outtextxy(" Tq "); Record.GetRectangle(5)->Outtextxy(" Tq/Ts "); Record.GetRectangle(6)->Outtextxy(" P1 "); Record.GetRectangle(12)->Outtextxy(" P2 "); Record.GetRectangle(18)->Outtextxy(" P3 "); Record.GetRectangle(24)->Outtextxy(" P4 "); Record.GetRectangle(30)->Outtextxy(" P5 "); setcolor(9); for (i=7,circle=0;i<=31,circle<Count;i=i+6,circle++) Record.GetRectangle(i)->Display(ArriveTime[circle]); for (i=8,circle=0;i<=32,circle<Count;i=i+6,circle++) Record.GetRectangle(i)->Display(Ts[circle]); } void InitGrid(void) { int number1=0,circle1,i; setcolor(11); outtextxy(155,155,"The Process Round Robin Scheduling"); setlinestyle(CENTER_LINE,1,1); line(15,175,610,175); setcolor(15); setlinestyle(DOTTED_LINE,1,0); for (i=0;i<5;i++) { for (circle1=0;circle1<40;circle1++) { Graph.NewRectangle(number1,15+circle1*15,200+i*20, circle1*15+30,200+(i+1)*20); number1=number1+1; } } } int IF_Finish(void) { if (Finish[0]+Finish[1]+Finish[2]+Finish[3]+Finish[4]==5) return 1; else return 0; } int LineTest(int a) { return (a*40); } void Kernel(void) { int i=0,j=0,IN=0,FillNumber=0,Order=0,StartNumber=0; int Clock=0,EndIn=0,Temp=0,Current=0; Node TempNode; Table[Order].SetID(0); Table[Order].SetCurrentLength(Ts[0]); while (IF_Finish()==0) { IN=0; TempNode=Table[Current]; StartNumber=LineTest(TempNode.GetID()); FillNumber=TempNode.GetCurrentLength()-Quantum; Temp=Clock; if (FillNumber<=0) { FillNumber=TempNode.GetCurrentLength(); Finish[TempNode.GetID()]=1; for (i=StartNumber+Temp;i<StartNumber+FillNumber+Temp;i++) { Graph.GetRectangle(i)->Fill(); Clock=Clock+1; for (j=0;j<Count;j++) if (Clock==ArriveTime[j]) { Table[Order+1].SetID(j); Table[Order+1].SetCurrentLength(Ts[j]); Order=Order+1; IN=1; if (j==Count-1) EndIn=1; } } EndTime[TempNode.GetID()]=Clock; while ((IN==0) && (IF_Finish()==0) && (EndIn==0)) { Clock=Clock+1; for (j=0;j<Count;j++) { if ((Clock==ArriveTime[j]) && (Finish[j]==0)) { Table[Order+1].SetID(j); Table[Order+1].SetCurrentLength(Ts[j]); Order=Order+1; IN=1; } } } } else { for (i=StartNumber+Temp;i<StartNumber+Quantum+Temp;i++) { Graph.GetRectangle(i)->Fill(); Clock=Clock+1; for (j=0;j<5;j++) if ((Clock==ArriveTime[j]) && (Finish[j]==0)) { Table[Order+1].SetID(j); Table[Order+1].SetCurrentLength(Ts[j]); Order=Order+1; if (j==Count-1) EndIn=1; } } if (Finish[TempNode.GetID()]==0) { Table[Order+1].SetID(TempNode.GetID()); Table[Order+1].SetCurrentLength(FillNumber); Order=Order+1; } } Current=Current+1; } } void Result() { int i=0,circle=0; float Sum=0.0,Everage=0.0; for (i=0;i<Count;i++) { Tq[i]=EndTime[i]-ArriveTime[i]; TqTs[i]=(float (Tq[i]))/(float (Ts[i])); Sum=Sum+TqTs[i]; } Everage=Sum/Count; for (i=9,circle=0;i<=33,circle<Count;i=i+6,circle++) Record.GetRectangle(i)->Display(EndTime[circle]); for (i=10,circle=0;i<=34,circle<Count;i=i+6,circle++) Record.GetRectangle(i)->Display(Tq[circle]); setcolor(12); for (i=11;i<=35;i=i+6) Record.GetRectangle(i)->Outtextxy("Thinking..."); getch(); outtextxy(100,330,"----- Result -----"); gotoxy(19,23); printf("The Everage Time Of (Tq/Ts) IS : %f",Everage); getch(); } void Version() { setcolor(14); outtextxy(150,400," DESIGNED BY NEWTRUMP 2001.01.01 "); outtextxy(150,420," Version 1.0 "); }
评论
    相关推荐
    • scheduling.zip
      关于调度算法的经典文献,适用于很多资源调度的应用场景。
    • roud-robin-scheduling.rar
      经典的网球循环赛日程算法设计 利用了分治算法
    • Round-robin-and-priority-scheduling.rar
      时间片轮转算法和优先级调度算法 C语言模拟实现
    • Round-robin-scheduling-algorithm-RR.rar
      时间片轮转RR进程调度算法,已通过验证的代码,可正常运行,有注释
    • RoundRobin.zip
      CPU Scheduling Round Robin
    • Round-Robin.zip
      Round robbin priority scheduling algorithm
    • Round-Robin-time-slice.rar
      时间片轮转法:程序模拟进程的时间片轮转RR调度过程。Time slice Round-Robin: program to simulate the process time slice rotation RR scheduling process.
    • lab-scheduling
      本实验旨在涵盖操作系统中使用的不同类型的调度,例如Round Robin。 请确保您在这些实验室中对问题的所有答案均来自在Edlab环境中完成的工作–否则,结果可能不一致,并且不会获得分数。 请在作业上以Grade Lab标记...
    • double_round_robin_schedule
      gem 'double_round_robin_schedule' 然后执行: $ bundle 或者自己安装: $ gem install double_round_robin_schedule 用法 require "double_round_robin_schedule" # Compute all the possible teams for ...
    • OS_deadlock_scheduling_algorithms:调度算法(Round Robin,SJF,Priority,
      OS_deadlock_scheduling_algorithms:调度算法(Round Robin,SJF,Priority,FCFS)和避免死锁算法(Banker's Algorithm)的实现