国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

進程 調度模擬程序

2019-11-02 15:21:23
字體:
來源:轉載
供稿:網友

 我們課程設計,我選擇了一個進程調度模擬,希望大家給看看,多提意見,好久沒來發帖子了。

  #include<iostream.h>

  #include<stdlib.h>

  #include<time.h>

  #include<stdio.h>

  #include<string.h> const int MAXCOMMANDLEN =50; /////////////////////////////////////////////////////////////////////////////////////

  //

  // PROCESS

  //

  /////////////////////////////////////////////////////////////////////////////////////

  class Process //進程類

  {

  friend class CPU;

  protected:

  static int init_ID; //隨機進程ID

  int ID; //進程ID

  char runText[MAXCOMMANDLEN]; //進程指令數組

  int IP; //進程指令指針,保存進程指令執行到的具體位置

  bool ISuseSource; //此進程是否使用資源,ture:使用中 false : 未使用

  bool ISblocked; //此進程是否被阻塞 ture:阻塞 false :未阻塞

  int unitTime; //進程單位被cpu執行時間, 默認 1

  int blockTime; //進程被阻塞時間

  public:

  static void RandID(); //隨機生成進程ID

  Process();

  int getID();

  int getIP();

  void setIP(int);

  void Runed(); //進程被cpu執行

  int getUnittime(); //得到進程單位執行時間

  int getBlcoktime(); //得到進程阻塞時間

  void setBlocktime(int); //設置進程阻塞時間

  void setUnittime(int); //設置進程單位執行時間

  char getResult(int); //得到進程執行結果

  char* getRuntext(); //得到進程執行的指令

  void setBlockstate(bool); //設置阻塞狀態

  bool getBlockstate();

  bool getISusesource(); //得到資源的狀態 使用 未使用

  void setISusesource(bool); //設置資源的使用狀態

  }; int Process::init_ID; void Process::RandID()

  {

  srand( (unsigned)time( NULL ) );

  init_ID=rand();

  }

  Process::Process()

  {

  ID=init_ID++;

  int commandLen;

  IP=0; cout<<"Please in put the text which process runed by CPU [#command#] :> ";

  cin>>runText;

  if( (commandLen=strlen(runText) ) > MAXCOMMANDLEN )

  exit(0);

  runText[commandLen]='#'; // 指令結束標志 '#'

  runText[commandLen+1]='';

  ISuseSource=false;

  ISblocked=false;

  unitTime=1;

  blockTime=0;

  }

  void Process::Runed()

  int Process::getID()

  {

  return ID;

  } int Process::getIP()

  {

  return IP;

  } void Process::setIP(int ip)

  bool Process::getISusesource()

  {

  return ISuseSource;

  } void Process::setISusesource(bool s)

  char* Process::getRuntext()

  {

  return runText;

  } int Process::getUnittime()

  {

  return unitTime;

  }

  int Process::getBlcoktime()

  {

  return blockTime;

  } void Process::setBlocktime(int BT)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 任丘市| 庄浪县| 盘山县| 于都县| 峨山| 西和县| 扎囊县| 英山县| 蒙山县| 阳原县| 丰顺县| 大同县| 沈丘县| 呈贡县| 化德县| 咸宁市| 将乐县| 化州市| 华宁县| 金门县| 共和县| 革吉县| 双江| 揭阳市| 西城区| 昭平县| 抚顺市| 湾仔区| 乐山市| 阿城市| 衡山县| 隆化县| 石楼县| 莱芜市| 英德市| 虞城县| 天台县| 金寨县| 关岭| 济源市| 西丰县|