⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 (1) 设计五个原语来实现对进程的控制。 (2) 五个原语如下:进程调度、创建原语、撤销原语、堵塞原语、唤醒原语。
💻 CPP
字号:
#include "stdafx.h"

#include <string.h>
#include <stdlib.h>
#include <conio.h>

#include "process.h"

int PrintPrompt(void){
	printf("\n            ************模拟操作系统进程队列************");
	printf("\n                            1.创建进程");
	printf("\n                            2.撤销原语");
	printf("\n                            3.进程调度");
	printf("\n                            4.堵塞原语");
	printf("\n                            5.唤醒原语");
	printf("\n                            0.Exit");
	printf("\n                       Please select==>(0-5):");
	printf("\n            *****copyright@wujianfei1988@hotmail.com*****\n");
	
	return 0;
}

int main(int argc, char* argv[])
{
	Linkpcb  *ready,*run,*wait;

    ready=InitPCBqueue();
    run=InitPCBqueue();
	wait=InitPCBqueue();
  	char cc=' ';
    PrintPrompt();
	while(cc!='0'){
		switch(cc=getch()){
          case '1':
			  printf("\n*****创建进程*****\n");
			  creat(ready);
			  printf("\nthe Queue of Ready's informations is:\n");
			  showqueue(ready);
			  printf("\n******操作完成*****\n");
			  break;
		  case '2':
			  printf("\n*****撤销原语*****\n");
			  printf("\n Before destroy the Queue of Run's informations is:\n");
              showqueue(run);
              printf("\n The Queue of Ready's informations is:\n");
              showqueue(ready);
              destroy(run);
			  scheduling(ready,run);
			  printf("\n After the Queue of Run's informations is:\n");
			  showqueue(run);
			  printf("\n The Queue of Ready's informations is:\n");
              showqueue(ready);
			  printf("\n******操作完成*****\n");
			  break;
	   	  case '3':
			  printf("\n*****进程调度*****\n");
 			  printf("\nBefore the scheduling:");
			  printf("\nthe Queue of Ready's informations is:\n");
			  showqueue(ready);
              printf("\nthe Queue of Run's informations is:\n");
			  showqueue(run); 
			  scheduling(ready,run); // *
			  printf("\nAfter the scheduling:");
			  printf("\nthe Queue of Ready's informations is:\n");
			  showqueue(ready);
              printf("\nthe Queue of Run's informations is:\n");
			  showqueue(run);
			  printf("\n******操作完成*****\n");
			  break;
		  case '4':
			  printf("\n*****堵塞原语*****\n");
 			  printf("\nBefore the blocking:");
              printf("\nthe Queue of Ready's informations is:\n");
			  showqueue(ready);
			  printf("\nthe Queue of Run's informations is:\n");
			  showqueue(run);
              printf("\nthe Queue of Wait's informations is:\n");
			  showqueue(wait); 
			  block(run,wait);
			  scheduling(ready,run);
			  printf("\nAfter the blocking:");
              printf("\nthe Queue of Ready's informations is:\n");
			  showqueue(ready);
			  printf("\nthe Queue of Run's informations is:\n");
			  showqueue(run);
              printf("\nthe Queue of Wait's informations is:\n");
			  showqueue(wait);
			  printf("\n******操作完成*****\n");
			  break;
		  case '5':
			  printf("\n*****唤醒原语*****\n");
 			  printf("\nBefore the wakeuping:");
			  printf("\nthe Queue of wait's informations is:\n");
			  showqueue(wait);
              printf("\nthe Queue of Ready's informations is:\n");
			  showqueue(ready); 
			  wakeup(wait,ready); // *
			  printf("\nAfter the wakeuping:");
			  printf("\nthe Queue of wait's informations is:\n");
			  showqueue(wait);
              printf("\nthe Queue of Ready's informations is:\n");
			  showqueue(ready);
			  printf("\n******操作完成*****\n");
			  break;
		  case '0':
			printf("\n *****ByeBye!!*****\n");
			break;
		  default:
			if((cc<'0') || (cc>'5')) PrintPrompt();
		}
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -