zoukankan      html  css  js  c++  java
  • process

    //时间轮转最多 轮转
    #include<iostream>
    #include<queue>
    using namespace std;
    struct node
    {
        friend bool operator< (node n1, node n2)
        {
            if(n1.t1<n2.t1)
       return false;
      if(n1.t1==n2.t1)
      {
       if(n1.t2<n2.t2)
        return true;
       if(n1.t2>n2.t2)
        return false;
      }
      return true;
        }
        int t1;//作业的到达时间
        int t2;//作业的运行时间
     int p;//进程的优先级
     char name[10];
    };
    struct Process//进程结构体
    {
     char name[10];
     int t;//运行时间
     int p;//进程优先级
     bool s;//进程的状态
     Process *next;
    };
    int clock;
    priority_queue<node> q;
    void creat_work()//作业随机产生随机个数的作业
    {
     int x=(rand()%10);
     while(x--)
     {
      clock=(clock+1)%1000;
      node work;

      work.name[0]=(rand()%128);
      work.name[1]=(rand()%128);
      work.name[2]=(rand()%128);
      work.name[3]=(rand()%128);

      work.t1=(rand()%1000);
      work.t2=(rand()%1000);
      work.p=(rand()%1000);
      clock+=3;
      clock%=1000;
      q.push(work);
     }
    }
    void creat_process()
    {

    }
    int main()
    {
        creat_work();//产生作业
     clock=0;
     creat_process();//产生进程;
     


     return 0;

    }

  • 相关阅读:
    合并本地多次commit为一个commit
    git 取消文件跟踪
    遍历进程 遍历窗口
    linux查看程序运行参数
    ubuntu下载地址
    将博客搬至CSDN
    extern"C"的使用
    ESP32-NVS存储(非易失性存储库)
    ESP32-EEPROM存储
    c语言简单数据类型
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/4516671.html
Copyright © 2011-2022 走看看