{"id":414,"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:41","modified_gmt":"2020-08-22T20:26:41","slug":"this-is-the-page-title-toplevel-247","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=414","title":{"rendered":"Wait Queues"},"content":{"rendered":"\n<title>Wait Queues<\/title>\n<p>\nThere are many times when a process must wait for a system resource.\nFor example a process may need the VFS inode describing a directory in the file system\nand that inode may not be in the buffer cache.\nIn this case the process must wait for that inode to be fetched from the physical\nmedia containing the file system before it can carry on.\n<p>\n<a name=\"tth_fIg11.4\"><\/a>\nwait_queue <br \/>\n<table border><tr><td>\n<p>\n*task\n<tr><td>\n*next<\/table>\n<p>\nFigure: Wait Queue\n<p>\n<p>\nThe Linux kernel uses a simple data structure, a wait queue (see the figure above),\nwhich consists of a pointer to the processes <tt>task_struct<\/tt> and a pointer to the\nnext element in the wait queue.\n<p>\nWhen processes are added to the end of a wait queue they can either be interruptible or\nuninterruptible.\nInterruptible processes may be interrupted by events such as timers expiring or\nsignals being delivered whilst they are waiting on a wait queue.\nThe waiting process&#8217; state will reflect this and either be <tt>INTERRUPTIBLE<\/tt> or\n<tt>UNINTERRUPTIBLE<\/tt>.\nAs this process can not now continue to run, the scheduler is run and, when it selects\na new process to run, the waiting process will be suspended.\n<p>\nWhen the wait queue is processed, the state of every process in the wait queue is set to\n<tt>RUNNING<\/tt>.\nIf the process has been removed from the run queue, it is put back onto the run queue.\nThe next time the scheduler runs, the processes that are on the wait queue are now candidates\nto be run as they are now no longer waiting.\nWhen a process on the wait queue is scheduled, the first thing that it will do is remove\nitself from the wait queue.\nWait queues can be used to synchronize access to system resources and they are used by Linux in\nits implementation of semaphores (see <site id=\"268\">here<\/site>).\n","protected":false},"excerpt":{"rendered":"<p>Wait Queues There are many times when a process must wait for a system resource. For example a process may need the VFS inode describing a directory in the file system and that inode may not be in the buffer &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=414\">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-414","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/414","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=414"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/414\/revisions"}],"predecessor-version":[{"id":788,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/414\/revisions\/788"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}