摘要:// sun.cpp : 定义控制台应用程序的入口点。 //本算法包含四种调度:先到先服务,短作业优先,时间片轮转,优先级调度 #include #define N 50 void main() { void fcfs(); //先来先服务 void sjf(); //短作业优先 void rr(); //时间片轮转 void yxj(); //优先级调度 i...
阅读全文
摘要:#include #include #include #include #define maxsize 1000 /*********************判断输入数据是否有效**************************/ int decide(char str[]) //判断输入数据是否有效 { int i=0; while(str[i]!='\0') { i...
阅读全文
摘要:#include #include #include void Print(int bc[],int blockCount) { int i; for(i=0;i=k) { k=a[i]; j=i; } } return j; } void LRU(int pc[],int bc[],int pageCount,int blockCount)...
阅读全文
摘要:#include #include /*全局变量*/ int mSIZE; //物理块数 int pSIZE; //页面号引用串个数 static int memery[10]={0}; //物理块中的页号 static int page[100]={0}; //页面号引用串 static int temp[100][10]={0}; //辅助数组 /*置换算法函数*...
阅读全文
摘要:#include ////////////////////////////////////////////////////////////////////////// //全局变量定义 int Available[100]; //可利用资源数组 int Max[50][100]; //最大需求矩阵 int Allocation[50][100]; //分配矩阵 int Need[50][...
阅读全文
摘要:#include int curr[5][5], maxclaim[5][5], avl[5]; int alloc[5] = {0, 0, 0, 0, 0};//已分配的资源 int maxres[5], running[5], safe=0; int count = 0, i, j, exec, r, p, k = 1; void main() { printf("\n请输入进程...
阅读全文
摘要:/*非抢占式优先级调度算法*/ #include using namespace std; struct Num { int priority; //优先级 int dt; //到达时间 int st; //运行时间 }sum[5]={{2,0,3},{3,2,2},{5,2,5},{1,5,3},{4,8,1}}; int main() { int c=0; //...
阅读全文
摘要:/*抢占式优先级调度算法*/ #include using namespace std; struct Num { int priority; //优先级 int dt; //到达时间 int st; //运行时间 int need_time; //还需运行的时间 }sum[5]={{2,0,3,3},{3,2,2,2},{5,2,5,5},{1,5,3,3},{4,8...
阅读全文
摘要:/*时间片轮转调度算法*/ #include #define MAX 50 struct a_struct { char name[10]; //进程名字 int number; //进程编号 float dt; //到达时间 float begin_time; //开始运行时间 float st; //服务时间 float end_time; //完成时间 in...
阅读全文
摘要:/* 短作业优先调度 */ #include struct sjf{ char name[10]; float dt;//到达时间 float st;//服务时间 float begin_time;//开始运行时间 float wct;//运行完成时间 float zt;//周转时间 float dczt;//带权周转时间 }; sjf a[100]; void input(s...
阅读全文
摘要:/* 先来先服务 */ #include #define MAX 50 struct Gzuo{ int id; //进程名字 int dt; //到达时刻 int st; //服务时间 int wct; //完成时刻 float zt; //周转时间 float dczt; //带权周转时间 }; Gzuo a[MAX]; void main(){ int i,j,min...
阅读全文