{"id":463,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:19","modified_gmt":"2020-08-22T20:26:19","slug":"this-is-the-page-title-toplevel-296","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=463","title":{"rendered":"Scheduling in Multiprocessor Systems"},"content":{"rendered":"\n<title>Scheduling in Multiprocessor Systems<\/title>\n<p>\nSystems with multiple CPUs are reasonably rare in the Linux world but a lot of work\nhas already gone into making Linux an SMP (Symmetric Multi-Processing) operating system.\nThat is, one that is capable of evenly balancing work between the CPUs in the system.\nNowhere is this balancing of work more apparent than in the scheduler.\n<p>\nIn a multiprocessor system, hopefully, all of the processors are busily running processes.\nEach will run the scheduler separately as its current process exhausts its time-slice\nor has to wait for a system resource.\nThe first thing to notice about an SMP system is that there is not just one idle process\nin the system.\nIn a single processor system the idle process is the first task in the <tt>task<\/tt> vector,\nin an SMP system there is one idle process per CPU, and you could have more than one idle CPU.\nAdditionally there is one current process per CPU, so SMP systems must keep track of\nthe current and idle processes for each processor.\n<p>\nIn an SMP system each process&#8217;s <tt>task_struct<\/tt> contains the number of the\nprocessor that it is currently running on\n(<tt>processor<\/tt>) and its processor number of the last processor that\nit ran on (<tt>last_processor<\/tt>).\nThere is no reason why a process should not run on a different CPU each time it is\nselected to run but Linux can restrict a process to one or more processors in the\nsystem using the <tt>processor_mask<\/tt>.\nIf bit N is set, then this process can run on processor N.\nWhen the scheduler is choosing a new process to run it will not consider one that\ndoes not have  the appropriate bit set for the current processor&#8217;s number in its <tt>processor_mask<\/tt>.\nThe scheduler also gives a slight advantage to a process that last ran on the\ncurrent processor because there is often a performance overhead when moving a\nprocess to a different processor.\n","protected":false},"excerpt":{"rendered":"<p>Scheduling in Multiprocessor Systems Systems with multiple CPUs are reasonably rare in the Linux world but a lot of work has already gone into making Linux an SMP (Symmetric Multi-Processing) operating system. That is, one that is capable of evenly &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=463\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-463","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=463"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/463\/revisions"}],"predecessor-version":[{"id":687,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/463\/revisions\/687"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}