answersLogoWhite

0

What is round-robin scheduling?

Updated: 8/10/2023
User Avatar

Wiki User

14y ago

Best Answer

The term round-robin often refers to something being done to many elements belonging to a group, one element at a time. It is the idea of the task being carried out "one element at a time" that is central here.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago
  1. #include
  2. #include
  3. #include
  4. #include
  5. #include
  6. #define N 100
  7. struct processors //PROCESS ATTRIBUTES//
  8. {
  9. float burst;
  10. float arrival;
  11. int priority;
  12. int num;
  13. }p[20],temp;
  14. struct ssss
  15. {
  16. int no;
  17. int xx;
  18. float arr;
  19. float burst;
  20. float ww;
  21. int pri;
  22. float wait;
  23. }process[N];
  24. void main()
  25. {
  26. void roundrobin(int);
  27. {
  28. //void graphics(float *,float,int);
  29. int i,j,c,n;float left,right,top,bottom;
  30. /* select a driver and mode that supports */
  31. /* multiple background colors. */
  32. int gdriver = EGA, gmode = EGAHI, errorcode;
  33. int bkcol, maxcolor, x, y;
  34. char msg[80];
  35. /* initialize graphics and local variables */
  36. initgraph(&gdriver, &gmode, "C:\\TC\\BGI");
  37. /* read result of initialization */
  38. errorcode = graphresult();
  39. if (errorcode != grOk) /* an error occurred */
  40. {
  41. printf("Graphics error: %s\n", grapherrormsg(errorcode));
  42. printf("Press any key to halt:");
  43. getch();
  44. exit(1); /* terminate with an error code */
  45. }
  46. cleardevice();//Gets the input from the user//
  47. printf("ENTER THE NUMBER OF PROCESSES:\t");
  48. scanf("%d",&n);
  49. for(i=0;i
  50. {
  51. gotoxy(22,2);
  52. printf("PROCESS:%d\n",i+1);
  53. printf("BURST TIME :\t");
  54. scanf("%f",&p[i].burst);
  55. printf("ARRIVAL TIME :\t");
  56. scanf("%f",&p[i].arrival);
  57. printf("PRIORITY :\t");
  58. scanf("%d",&p[i].priority);
  59. p[i].num = i+1;
  60. if(p[i].arrival < 0 p[i].burst <=0 p[i].priority > n p[i].burst> 40)
  61. {
  62. printf("\n\nINVALID INPUT\n");
  63. printf("PLEASE RE ENTER THE PARAMETERS FOR PROCESS %d",i+1);
  64. i--;
  65. getch();
  66. }
  67. cleardevice();
  68. }
  69. for(i=0;i
  70. {
  71. for(j=i;j
  72. {
  73. if(p[i].arrival > p[j].arrival)
  74. {
  75. temp = p[i];
  76. p[i] = p[j];
  77. p[j] = temp;
  78. }
  79. }
  80. }
  81. void roundrobin(int n)
  82. {
  83. int i,j,l=0,pr[30];float tot[10]={1,1,1,1,1,1,1,1,1,1},s[10]={0,0,0,0,0,0,0,0,0,0},c=1,y=0;
  84. float q,awt,total=0,wt[10]={0,0,0,0,0,0,0,0,0,0},g[400];
  85. void graphics(float *,float,int,float *,int,int *,int);
  86. cleardevice();
  87. printf("Enter the time quantum: ");
  88. scanf("%f",&q);
  89. for(i=0;i
  90. {
  91. tot[i] = p[i].burst;
  92. }
  93. g[y++] = total;
  94. g[y++] = 0;
  95. g[y++] = total = total + p[0].arrival;
  96. while(c<=n) //Keeps track of the processes that are completed
  97. {
  98. for(i=0;i
  99. {
  100. if(tot[i]>0) //Checks whether the process is over or not
  101. {
  102. tot[i] = tot[i] - q; //decreases the burst time by the
  103. //time quantum
  104. if(tot[i]<=0) // checks whether this is the last
  105. //round for this process
  106. {
  107. g[y++] = p[i].num;
  108. g[y++] = total = total + tot[i] + q;
  109. //calculates the waiting time of the proces
  110. wt[i] = total - p[i].burst - p[i].arrival;
  111. //checks whether a process has arrived in the mean time
  112. if(total>=p[i+1].arrival)
  113. {
  114. i++;
  115. }
  116. else
  117. {
  118. i=0;
  119. }
  120. c++;
  121. }
  122. else
  123. {
  124. g[y++] = p[i].num;
  125. g[y++] = total = total + q;
  126. while(tot[i+1]<=0)//increments 'i' till it reaches an incomplete
  127. i++; //process
  128. if(total>=p[i+1].arrival)
  129. {
  130. i++;
  131. }
  132. else
  133. {
  134. i=0;
  135. }
  136. }
  137. }
  138. else
  139. {
  140. i++;
  141. if(p[i].arrival > total) //checks for idle time
  142. {
  143. if(i<=n)
  144. {
  145. g[y++] = 0;
  146. g[y++] = total = p[i].arrival;
  147. }
  148. else if(i==n-1 && c==n-1)
  149. {
  150. g[y++] = 0;
  151. g[y++] = total = p[i].arrival;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. g[y++] = p[i-1].num;
  158. q=0;
  159. for(i=0;i
  160. {
  161. //printf("%d. %f\n",p[i].num,wt[i]);
  162. q = q + wt[i];
  163. }
  164. awt = q/n;
  165. graphics(wt,awt,n,g,y,pr,l);
  166. outtextxy(200,0,"FOR ROUND ROBIN SCHEDULING");
  167. getch();
  168. }
  169. void graphics(float *wt,float awt,int n,float *g,int y,int *pr,int l)
  170. {
  171. int i,msg1=0,j=0,u=0;
  172. char msg[30];
  173. float left,right,top,bottom,awd=0,turn=0,d=0;
  174. getch();
  175. cleardevice();
  176. setlinestyle(4, 1, 1);
  177. setfillstyle(10,1);
  178. bar3d(0,0,620,340,0,0);
  179. line(0, 2, 618, 2);
  180. line(2,2,2,338);
  181. line(2,338,618,338);
  182. line(618,338,618,2);
  183. setlinestyle(0,1,1);
  184. left = 0;
  185. top = 40;
  186. bottom = 80;
  187. right = 15;
  188. for(i=0;i
  189. {
  190. left = right;
  191. right = *(g+i);
  192. right = (15-j) * (right - u);
  193. bar3d(left,top,right,bottom,0,0);
  194. sprintf(msg,"%2.1f",*(g+i));
  195. outtextxy(right,(82+msg1),msg);
  196. i++;
  197. setfillstyle(1,*(g+i));
  198. if(right>=600)
  199. {
  200. right = 0;
  201. top = 120;
  202. bottom = 160;
  203. msg1 = 82;u= *(g+i-1);
  204. i--;
  205. outtextxy(right,164,msg);
  206. i++;
  207. }
  208. delay(500);
  209. }
  210. setcolor(CYAN+BLINK);
  211. settextstyle(DEFAULT_FONT, HORIZ_DIR, 0);
  212. sprintf(msg,"AVERAGE WAITING TIME : %f",awt);
  213. outtextxy(20,30,msg);
  214. for(i=0;i
  215. {
  216. d = d + p[i].burst;
  217. }
  218. awd = d/n;
  219. turn = awd + awt;
  220. //settextstyle(DEFAULT_FONT, HORIZ_DIR, 4);
  221. sprintf(msg,"AVERAGE TURN AROUND TIME : %f",turn);
  222. outtextxy(300,30,msg);
  223. setcolor(WHITE);
  224. sprintf(msg,"PROCESS");
  225. outtextxy(32,210,msg);
  226. sprintf(msg,"WAITING TIME");
  227. outtextxy(190,210,msg);
  228. outtextxy(340,210,"COLORS");
  229. outtextxy(410,210,"IDLE");
  230. setfillstyle(1,0);
  231. bar3d(455,206,515,216,0,0);
  232. for(i=0;i
  233. {
  234. sprintf(msg,"%d.",p[i].num);
  235. outtextxy(48,226+(i*17),msg);
  236. sprintf(msg,"%f",*(wt+i));
  237. outtextxy(208,226+(i*17),msg);
  238. if(i==6)
  239. break;
  240. }
  241. //getch();
  242. //cleardevice();
  243. /*for(i=7;i
  244. {
  245. sprintf(msg,"%d.",p[i].num);
  246. outtextxy(48,226+((i-7)*17),msg);
  247. sprintf(msg,"%f",*(wt+i));
  248. outtextxy(208,226+((i-7)*17),msg);
  249. } */
  250. for(i=0;i
  251. {
  252. setfillstyle(1,p[i].num);
  253. bar3d(330,225+(i*17),390,235+(i*17),0,0);
  254. if(i==6)
  255. break;
  256. }
  257. settextstyle(TRIPLEX_FONT, HORIZ_DIR,2 );
  258. outtextxy(50,0,"GANTT CHART");
  259. if(n>=7)
  260. {
  261. getch();
  262. cleardevice();
  263. settextstyle(DEFAULT_FONT,HORIZ_DIR,0);
  264. sprintf(msg,"PROCESS");
  265. outtextxy(32,10,msg);
  266. sprintf(msg,"WAITING TIME");
  267. outtextxy(190,10,msg);
  268. outtextxy(340,10,"COLORS");
  269. outtextxy(410,10,"IDLE");
  270. setfillstyle(1,0);
  271. bar3d(455,6,515,16,0,0);
  272. for(i=7;i
  273. {
  274. sprintf(msg,"%d.",p[i].num);
  275. outtextxy(48,26+((i-7)*17),msg);
  276. sprintf(msg,"%f",*(wt+i));
  277. outtextxy(208,26+((i-7)*17),msg);
  278. }
  279. for(i=7;i
  280. {
  281. setfillstyle(1,p[i].num);
  282. bar3d(330,25+((i-7)*17),390,35+((i-7)*17),0,0);
  283. }
  284. }
  285. getch();
  286. }
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is round-robin scheduling?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Round robin scheduling program in java?

Round robin is the scheduling algorithm that is utilized by the CPU, or central processing unit, during the execution of the process. It is specifically designed for time sharing systems.


What is the Least Slack Time scheduling algorithm used for?

The Least Slack Time scheduling algorithm is used for assigning priority based on the slack time (temporal difference between the deadline, ready time and run time) of a process.


Compute the average waiting time and average turnaround time for each what scheduling algorithms and determine which one gives the best results. a.FCFS b.SJN c.SRT d.round robin?

c program for shortest remaining time scheduling algo


How do veterinarians use computers?

A system could contain one or many of the following: *A time tracker *A customer scheduling system *Visiting and contact information tracker *Online payments and scheduling *Customer medical history *Billing *Online promotions and reminders


what are advantages and disadvantages of Round Robin scheduling algorithm?

Pure round robin scheduling processes A, then B, then C, then starts at A again. (A, B, C might be tasks in an operating system context, or devices in a master/slave control network, or whatever.) That is, pure round robin scheduling doesn't acknowledge priorities, and does not allow out-of-order processing. Real-life systems typically use a mixture of algorithms that, together, allow for prioritized and out-of-order processing while, on the other hand, trying to prevent starvation of lower priority items.

Related questions

Why in round robin new processes place at end of queue rather than at beginning?

in roundrobin scheduling each process is gven a fixed time to execute so whenever a new process arrives it is placed at the end of the queue,,,,,the advantage by doing this type of scheduling is response time will be gud...But the disadvantage waiting time is more


What are the disadvantages of RoundRobin Scheduling?

Pure round robin scheduling processes A, then B, then C, then starts at A again. (A, B, C might be tasks in an operating system context, or devices in a master/slave control network, or whatever.) That is, pure round robin scheduling doesn't acknowledge priorities, and does not allow out-of-order processing. Real-life systems typically use a mixture of algorithms that, together, allow for prioritized and out-of-order processing while, on the other hand, trying to prevent starvation of lower priority items.


What is local scheduling and global scheduling?

i do no...............


What type of scheduling is there in RTOS?

A scheduler is the heart of every RTOS. It provides the algorithms to select the task for execution. Three common scheduling algorithms are &gt; Cooperative scheduling &gt; Round-robin scheduling &gt; Preemptive scheduling RTOS uses preemptive (priority based) scheduling. In some cases, real-time requirements can be met by using static scheduling.


What is the meaning of sequential scheduling?

It means scheduling one after another.


What is stream scheduling?

Stream Scheduling is a scheduling system where there is a steady stream/flow of patients at set appointments throughout the day.


What is disk scheduling in operating system?

why we use disk scheduling in c ?


Priority scheduling positive and negative points?

disadvantages of priority scheduling


What is priority scheduling algorithm?

The priority scheduling algorithm is a kind of CPU scheduling algorithm where the processes that wait for the CPU are scheduled according to their priority..


Where can scheduling program software be downloaded?

Scheduling program software can be downloaded from a number of companies such as Amazon. Amazon has a large selection of scheduling programs from various vendors.


How would you differentiate dynamic scheduling and dynamic inventory?

How would you differentiate dynamic scheduling and dynamic inventory? How would you differentiate dynamic scheduling and dynamic inventory?


Facilities Scheduling?

Facilities Scheduling is used to schedule date and time slots for facilities in order to ensure that there are no scheduling conflict between any parties and to facilitate planning.