{"id":6273,"date":"2025-09-16T11:26:19","date_gmt":"2025-09-16T05:56:19","guid":{"rendered":"https:\/\/study.madeeasy.in\/?p=6273"},"modified":"2025-09-16T11:26:19","modified_gmt":"2025-09-16T05:56:19","slug":"critical-section-and-race-condition","status":"publish","type":"post","link":"https:\/\/www.madeeasy.in\/study\/cs-it\/operating-system\/critical-section-and-race-condition","title":{"rendered":"Critical Section and Race Condition"},"content":{"rendered":"<ol>\n<li><strong>Critical Section:<\/strong> The portion of program text where the shared variables or shared resources will be placed.<\/li>\n<li><strong>Race Condition:<\/strong> It is a bug which occurs when the final value of the shared variable depends onexecution sequence of the processes.<br \/>\nSeveral processes access and process the manipulations over the same data concurrently, then the outcome depends on the particular order in which the access takes place.<br \/>\n\u2022 To avoid race condition, only one process should be allowed into critical section at any point of time.<\/li>\n<\/ol>\n<p><strong> THE CRITICAL-SECTION PROBLEM<\/strong><\/p>\n<ol>\n<li>The critical-section problem is to design a protocol using which the processes can cooperate. The protocol must ensure that when one process is executing in its critical section, no other process is allowed to execute in its critical section.<\/li>\n<li>The critical section problem is to design a protocol that the processes can use so that their action will not depend on the order in which their execution is interleaved (possibly on many processors).<\/li>\n<\/ol>\n<p><strong>Template for each process that involves a critical section:<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6274 size-full\" src=\"https:\/\/study.madeeasy.in\/wp-content\/uploads\/2025\/09\/critical-section.jpg\" alt=\"Critical Section\" width=\"393\" height=\"121\" srcset=\"https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/09\/critical-section.jpg 393w, https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/09\/critical-section-300x92.jpg 300w, https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/09\/critical-section-390x121.jpg 390w\" sizes=\"auto, (max-width: 393px) 100vw, 393px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Critical Section: The portion of program text where the shared variables or shared resources will be placed. Race Condition: It<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[94,3],"tags":[1854,1855],"class_list":["post-6273","post","type-post","status-publish","format-standard","hentry","category-operating-system","category-cs-it","tag-critical-section","tag-race-condition"],"_links":{"self":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/comments?post=6273"}],"version-history":[{"count":0,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6273\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/media?parent=6273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/categories?post=6273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/tags?post=6273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}