round robin schedule(循环日程表)

the source of the article:https://github.com/Fibird/Round-robin-schedule

#include <iostream>
#include <math.h>

#define N 3

using namespace std;

int main()
{
int sche = pow(2.0, N); //the number of athlete
int **arr = new int*[sche];
int bw = 1;
for(int i=0; i<sche; i++)
{
arr[i] = new int[sche];
}
int bid; //the id of block
int c_offset, r_offset;

//init line 1 with 1 to 8
for(int i=0; i<sche; i++)
arr[0][i] = i + 1;

for(int j=0; j<N; j++)
{
for(int r=0; r<bw; r++)
{
for(int c=0; c<sche; c++)
{
bid = (c + bw) / bw;
c_offset = pow(-1.0, bid+1) * bw; //move to right or move to left bw location
r_offset = bw;
arr[r + r_offset][c + c_offset] = arr[r][c];
}
}
bw = bw * 2; //every loop the problem will double
}

// outputs the schedule of the round robin
cout << "N/D";
for(int i=1; i<sche; i++)
cout << "\t" << i;
cout << endl;
for(int i=0; i<sche; i++)
{
cout << arr[i][0];
for(int j=1; j<sche; j++)
{
cout << "\t" << arr[i][j];
}
cout << endl;
}

//free memory
for(int i=0; i<sche; i++)
delete arr[i];
delete arr;
return 0;

}

时间: 2024-11-05 02:21:19

round robin schedule(循环日程表)的相关文章

HNU Round Robin (约瑟夫)

Round Robin Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB Total submit users: 37, Accepted users: 30 Problem 12940 : No special judgement Problem description Suppose that N players sit in order and take turns in a game, with the

Round robin

http://www.computerhope.com/jargon/r/rounrobi.htm Round robin Round robin is a method of distributing multiple sources to one of the many devices or connections. For example, a company may have multiple servers that are identical to each other. When

MIT JOS # Round&#173;Robin Scheduling#

MIT JOS # Round-Robin Scheduling# 下面是MIT JOS里 round-robin调度策略的实现. 在 kern/sched.c里面 下面的截图来自<<Modern Operating system>> (以前搬过的砖也是有好处的哇-) 结合代码就能够很形象的理解Round-robin. 每当我们调用sched_yeild()的时候,我们就打算让当前进程让出CPU了. 于是把 idle = thiscpu->cpu_env; 我们每次都让出当前

Set the Round Robin IOPS limit from 1000 to 1

https://kb.vmware.com/s/article/2069356 http://www.enterprisedaddy.com/2017/02/set-round-robin-iops-limit-default-1000-1-using-powercli/ 1,Query the paths of the LUNesxcli storage nmp path list --device naa.60000971111492600622233032393333 2,Set the

循环日程表问题(分治)

---恢复内容开始--- 题意 : 给出 n  = 2k个参赛者,要求每一个参赛者必须与其他 n-1 个选手各赛一次,每个选手一天只能赛一次,循环赛一共进行 n-1 天, 按照此要求设计一张比赛日程表, 使得该表有 n 行和 n-1 列,第 i 行 j 列为第 i 个选手第 j 天遇到的选手. 分析 : 刘大爷给出了一个分治的想法,当 k = 2也就是有 4 名选手的时候,左上角可以直接 1 和 2 去比,左下角是左上角每一个数 +2 得到,而右上角和右下角分别是左下角和左上角复制得到,也就是说

操作系统,时间片轮转算法的C语言实现Round Robin

1 #include "windows.h" 2 #include <conio.h> 3 #include <stdlib.h> 4 #include <fstream.h> 5 #include <io.h> 6 #include <string.h> 7 #include <stdio.h> 8 9 void Create_ProcInfo(); // 建立进程调度需要的数据 10 void Display_

Linux内核源代码情景分析-wait()、schedule()

父进程执行wait4,并调用schedule切换到子进程: wait4(child, NULL, 0, NULL); 像其他系统调用一样,wait4()在内核中的入口是sys_wait4(),代码如下: asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struct rusage * ru)//pid为子进程的进程号 { int flag, retval; DECLARE_WAITQUEUE(wa

Set VM RDM disk to Round Bobin and set IOPS path to 1

KB Related to IOPS setting Adjusting Round Robin IOPS limit from default 1000 to 1 (2069356) https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2069356 To adjust the IOPS parameter from the default 1000

Spark Executor Driver资源调度小结

一.引子 在Worker Actor中,每次LaunchExecutor会创建一个CoarseGrainedExecutorBackend进程,Executor和CoarseGrainedExecutorBackend是1对1的关系.也就是说集群里启动多少Executor实例就有多少CoarseGrainedExecutorBackend进程. 那么到底是如何分配Executor的呢?怎么控制调节Executor的个数呢? 二.Driver和Executor资源调度 下面主要介绍一下Spark