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

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

進程調度模擬程-序

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

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

  #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()

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新乡市| 潢川县| 鲁甸县| 南木林县| 日土县| 新野县| 乌兰浩特市| 郑州市| 扎鲁特旗| 亚东县| 通化市| 肥西县| 平罗县| 景东| 平塘县| 水富县| 简阳市| 西吉县| 岑溪市| 临武县| 正镶白旗| 冀州市| 奉节县| 安阳市| 营山县| 吉林市| 宜丰县| 稻城县| 皋兰县| 台州市| 海原县| 云龙县| 华池县| 阿拉善盟| 涿鹿县| 巴塘县| 拜城县| 太仓市| 灵台县| 崇文区| 德兴市|