如何找到循环的平均等待时间及其随着时间的流逝
How to Find the average waiting time of a round robin and its turn over time
所以我在如何创建代码,甚至是如何获取循环计划的平均时间的公式以及随着时间的流逝的转弯是我的代码是我的代码,这是我的代码罗宾人可以给我一些提示吗?如何改进我的代码?以及如何获得平均等待时间?
#include<iostream>
using namespace std;
int main(){
int number;
int interval;
cout<<"How many Process Need: ";
cin>>number;
cout<<"Time Quantum: ";
cin>>interval;
int array[number];
for(int i=0;i<number;i++)
{
cout<<"Process Time for Job "<<i+1<<": ";
cin>>array[i];
}
for(int z=0;z<number;z++)
{
for(int i=0;i<number;i++)
{
if(array[i]-interval>=interval-1)
{
for(int x=1;x<=interval;x++)
{
cout<<"Job "<<i+1<<"t";
}
array[i]=array[i]-interval;
}
else
{
for(int x=1;x<=array[i];x++)
{
cout<<"Job "<<i+1<<"t";
}
array[i]=0;
}
}
}
cout<<endl;
system("pause");
return 0;
}
我不完全确定您要使用源代码要实现的目标,但是肯定不会"测量" RR计划方案中的平均等待时间和随着时间的流逝。
如果您确实想介绍给定的OS的RR方案,则需要解决内核空间。目前,我能想到的是,您需要使用诸如struct timespec
之类的东西来捕获微型第二级的时间戳。在内核空间中,每当调用一个过程时,都会捕获时间戳。之后您必须统计地分析这些时间戳。
以上是软件解决方案。我曾经使用过的硬件解决方案涉及具有已知给定频率和计数器的振荡器。每次在内核中调用一个过程时,我都会将FPGA计数器值推到缓冲区。通过将缓冲区推到文件并与Excel进行分析,我能够确定内核RR调度方案。
不确定以上是否有帮助。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- 从持续时间构造std::chrono::system_clock::time_point
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- while循环中while循环的时间复杂度是多少
- 使用简单类型列表实现的指数编译时间.为什么
- 是否可以在编译时初始化数组,以便在运行时不会花费时间?
- 在已经使用Git的情况下减少编译时间
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 如何将包含epoch时间的十六进制字符串转换为time_t
- 从文本文件中读取时钟时间和事件时间并进行处理
- 具有未知值时的时间复杂性
- 如何减少花费的时间
- C++在变量给定的指定时间内关闭电脑
- rcpp函数中的清理时间很长
- C++:floor unix时间戳到UTC月份
- 如何在c++中录制具有精确帧时间戳的视频
- 如何模拟时间的流逝来调试程序?
- QT -Qtreeview随着时间的流逝而开始表现出奇怪的行为
- 随着时间的流逝,C 会减慢读取70,000个文件
- 如何找到循环的平均等待时间及其随着时间的流逝