{"id":65,"date":"2025-01-08T03:46:56","date_gmt":"2025-01-08T03:46:56","guid":{"rendered":"https:\/\/mitalgoswami.in\/?p=65"},"modified":"2025-07-17T06:51:09","modified_gmt":"2025-07-17T06:51:09","slug":"round-robin-rr-algorithm","status":"publish","type":"post","link":"https:\/\/mitalgoswami.in\/?p=65","title":{"rendered":"Round Robin (RR Algorithm)"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>Example:<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Given Processes:<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Process<\/th><th>Arrival Time<\/th><th>Burst Time<\/th><\/tr><\/thead><tbody><tr><td>P1<\/td><td>0<\/td><td>6<\/td><\/tr><tr><td>P2<\/td><td>1<\/td><td>8<\/td><\/tr><tr><td>P3<\/td><td>2<\/td><td>7<\/td><\/tr><tr><td>P4<\/td><td>3<\/td><td>3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Time Quantum: 4<\/h4>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 1: Process Execution<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>At <code>t=0<\/code>, P1 gets the CPU for 4 units. Remaining burst time: 2.<\/li>\n\n\n\n<li>At <code>t=4<\/code>, P2 executes for 4 units. Remaining burst time: 4.<\/li>\n\n\n\n<li>At <code>t=8<\/code>, P3 executes for 4 units. Remaining burst time: 3.<\/li>\n\n\n\n<li>At <code>t=12<\/code>, P4 executes for 3 units. Remaining burst time: 0 (P4 finishes).<\/li>\n\n\n\n<li>Back to P1, executes for 2 units (finishes at <code>t=17<\/code>).<\/li>\n\n\n\n<li>P2 resumes, executes for 4 units (finishes at <code>t=21<\/code>).<\/li>\n\n\n\n<li>P3 resumes, executes for 3 units (finishes at <code>t=24<\/code>).<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Gantt Chart<\/strong><\/h4>\n\n\n\n<p>| Time | 0 &#8211; 4 | 4 &#8211; 8 | 8 &#8211; 12 | 12 &#8211; 15 | 15 &#8211; 17 | 17 &#8211; 21 | 21 &#8211; 24 | |&#8212;&#8212;|&#8212;&#8212;-|&#8212;&#8212;-|&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;| | P | P1 | P2 | P3 | P4 | P1 | P2 | P3 |<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 2: Calculations<\/strong><\/h4>\n\n\n\n<p><strong>Turnaround Time (TAT)<\/strong> = Completion Time &#8211; Arrival Time<br><strong>Waiting Time (WT)<\/strong> = Turnaround Time &#8211; Burst Time<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Process<\/th><th>Arrival Time<\/th><th>Burst Time<\/th><th>Completion Time<\/th><th>TAT<\/th><th>WT<\/th><\/tr><\/thead><tbody><tr><td>P1<\/td><td>0<\/td><td>6<\/td><td>17<\/td><td>17<\/td><td>11<\/td><\/tr><tr><td>P2<\/td><td>1<\/td><td>8<\/td><td>21<\/td><td>20<\/td><td>12<\/td><\/tr><tr><td>P3<\/td><td>2<\/td><td>7<\/td><td>24<\/td><td>22<\/td><td>15<\/td><\/tr><tr><td>P4<\/td><td>3<\/td><td>3<\/td><td>15<\/td><td>12<\/td><td>9<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 3: Averages<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Average Turnaround Time (TAT):<\/strong> 17+20+22+124=17.75\\frac{17 + 20 + 22 + 12}{4} = 17.75417+20+22+12\u200b=17.75<\/li>\n\n\n\n<li><strong>Average Waiting Time (WT):<\/strong> 11+12+15+94=11.75\\frac{11 + 12 + 15 + 9}{4} = 11.75411+12+15+9\u200b=11.75<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Advantages of Round Robin<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Fair for all processes.<\/li>\n\n\n\n<li>Prevents starvation.<\/li>\n\n\n\n<li>Simple to implement.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Disadvantages of Round Robin<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>High context switching overhead.<\/li>\n\n\n\n<li>Performance depends heavily on the time quantum:\n<ul class=\"wp-block-list\">\n<li>A very small quantum increases overhead.<\/li>\n\n\n\n<li>A very large quantum reduces responsiveness and approximates FCFS scheduling.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Example: Given Processes: Process Arrival Time Burst Time P1 0 6 P2 1 8 P3 2 7 P4 3 3 Time Quantum: 4 Step 1: Process Execution Gantt Chart | Time | 0 &#8211; 4 | 4 &#8211; 8 | 8 &#8211; 12 | 12 &#8211; 15 | 15 &#8211; 17 | 17 &#8211; 21 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-unix"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65"}],"version-history":[{"count":1,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":66,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions\/66"}],"wp:attachment":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}