{"id":344,"date":"2025-11-13T03:29:02","date_gmt":"2025-11-13T03:29:02","guid":{"rendered":"https:\/\/mitalgoswami.in\/?p=344"},"modified":"2025-11-13T03:33:45","modified_gmt":"2025-11-13T03:33:45","slug":"priority-based-non-preemptive-and-priority-based-preemptive-scheduling","status":"publish","type":"post","link":"https:\/\/mitalgoswami.in\/?p=344","title":{"rendered":"Priority-Based Non-Preemptive and Priority-Based Preemptive Scheduling"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>1. Priority-Based Non-Preemptive Scheduling<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Definition:<\/strong><\/h3>\n\n\n\n<p>In <strong>Priority Non-Preemptive Scheduling<\/strong>, each process is assigned a <strong>priority<\/strong>.<br>The <strong>CPU is allocated to the process with the highest priority<\/strong> (smallest number = highest priority).<br>Once the CPU is given to a process, it <strong>cannot be taken away<\/strong> until the process finishes, even if a higher-priority process arrives.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Key Features:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Type:<\/strong> Non-preemptive<\/li>\n\n\n\n<li><strong>Basis:<\/strong> Process priority<\/li>\n\n\n\n<li><strong>Higher priority \u2192 executed first<\/strong><\/li>\n\n\n\n<li><strong>If priorities are same \u2192 FCFS<\/strong> is used<\/li>\n\n\n\n<li><strong>CPU is not interrupted<\/strong> once assigned<\/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>Example:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Process<\/th><th>Burst Time (ms)<\/th><th>Priority<\/th><\/tr><\/thead><tbody><tr><td>P1<\/td><td>10<\/td><td>3<\/td><\/tr><tr><td>P2<\/td><td>1<\/td><td>1<\/td><\/tr><tr><td>P3<\/td><td>2<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Execution Order:<\/strong><br>\u2192 P2 (Priority 1) \u2192 P3 (Priority 2) \u2192 P1 (Priority 3)<\/p>\n\n\n\n<p><strong>Gantt Chart:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>|  P2  |  P3  |  P1  |\n0      1      3     13\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Advantages:<\/strong><\/h3>\n\n\n\n<p>\u2705 Simple to implement<br>\u2705 Lower-priority tasks do not preempt higher-priority ones<br>\u2705 Good for batch systems<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Disadvantages:<\/strong><\/h3>\n\n\n\n<p>\u274c <strong>Starvation<\/strong> (low-priority processes may never execute)<br>\u274c No preemption \u2014 less responsive<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Priority-Based Preemptive Scheduling<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Definition:<\/strong><\/h3>\n\n\n\n<p>In <strong>Priority Preemptive Scheduling<\/strong>, the CPU is also assigned to the <strong>highest-priority process<\/strong>,<br><strong>but<\/strong> if a <strong>new process arrives with a higher priority<\/strong> than the currently running one, the CPU <strong>is preempted<\/strong> and given to the new process.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Key Features:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Type:<\/strong> Preemptive<\/li>\n\n\n\n<li><strong>CPU can be taken away<\/strong> if a higher-priority process arrives<\/li>\n\n\n\n<li><strong>Higher responsiveness<\/strong> than non-preemptive version<\/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>Example:<\/strong><\/h3>\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>Priority<\/th><\/tr><\/thead><tbody><tr><td>P1<\/td><td>0<\/td><td>5<\/td><td>2<\/td><\/tr><tr><td>P2<\/td><td>1<\/td><td>3<\/td><td>1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Execution Order:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>At time 0 \u2192 P1 starts (priority 2)<\/li>\n\n\n\n<li>At time 1 \u2192 P2 arrives (priority 1, higher) \u2192 <strong>P1 is preempted<\/strong><\/li>\n\n\n\n<li>CPU switches to P2 \u2192 completes<\/li>\n\n\n\n<li>Then P1 resumes<\/li>\n<\/ul>\n\n\n\n<p><strong>Gantt Chart:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>| P1 | P2 | P1 |\n0    1    4    9\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Advantages:<\/strong><\/h3>\n\n\n\n<p>\u2705 Better <strong>response time<\/strong> for high-priority processes<br>\u2705 More <strong>efficient CPU utilization<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Disadvantages:<\/strong><\/h3>\n\n\n\n<p>\u274c <strong>Starvation<\/strong> for low-priority processes<br>\u274c <strong>More context switches<\/strong> (less efficient)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"> <strong>Difference Summary:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Priority Non-Preemptive<\/th><th>Priority Preemptive<\/th><\/tr><\/thead><tbody><tr><td><strong>CPU control<\/strong><\/td><td>Process keeps CPU until completion<\/td><td>CPU can be taken by higher-priority process<\/td><\/tr><tr><td><strong>Response time<\/strong><\/td><td>Slower<\/td><td>Faster<\/td><\/tr><tr><td><strong>Context switching<\/strong><\/td><td>Less<\/td><td>More<\/td><\/tr><tr><td><strong>Starvation<\/strong><\/td><td>Possible<\/td><td>More likely<\/td><\/tr><tr><td><strong>Type<\/strong><\/td><td>Non-preemptive<\/td><td>Preemptive<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>1. Priority-Based Non-Preemptive Scheduling Definition: In Priority Non-Preemptive Scheduling, each process is assigned a priority.The CPU is allocated to the process with the highest priority (smallest number = highest priority).Once the CPU is given to a process, it cannot be taken away until the process finishes, even if a higher-priority process arrives. Key Features: Example: [&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-344","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\/344","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=344"}],"version-history":[{"count":1,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/344\/revisions"}],"predecessor-version":[{"id":345,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/344\/revisions\/345"}],"wp:attachment":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}