{"id":413,"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:39","modified_gmt":"2020-08-22T20:26:39","slug":"this-is-the-page-title-toplevel-246","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=413","title":{"rendered":"Task Queues"},"content":{"rendered":"\n<title> Task Queues<\/title>\n<img decoding=\"async\" src=\"tqueue.gif\">\n<p>\nFigure: A Task Queue<\/center>\n<p>\n<p>Task <glossary>queue<\/glossary>s are the <glossary>kernel<\/glossary>&#8216;s way of deferring work until later.\nLinux queues work using a generic mechanism, so it can processes the queues\nlater.\n<p>\nTask <glossary>queue<\/glossary>s are often used in conjunction with bottom half handlers; the timer task\nqueue is processed when the timer queue bottom half handler runs.\nA task queue is a simple data structure, see figure&nbsp;<a href=\"#tq-figure\">\n11.2<\/a> which consists\nof a singly linked list of <tt>tq_struct<\/tt> data structures each of which contains\nthe address of a routine and a pointer to some data.\n<p>\nThe routine will be called when the element on the task queue is processed and it will\nbe passed a pointer to the data.\n<p>\nAnything in the kernel, for example a device driver, can create and use task\n<glossary>queue<\/glossary>s but there are three task queues created and managed by the\n<glossary>kernel<\/glossary>:\n<dl compact>\n\t<dt><b>timer<\/b><\/dt><dd> This <glossary>queue<\/glossary> is used to queue work\n        that will be done as soon after\n\tthe next system <glossary>clock tick<\/glossary> as is possible. Each <glossary>clock tick<\/glossary>, this queue\n\tis checked to see if it contains any entries and, if it does, the timer\n\tqueue bottom half handler is made active. The timer <glossary>queue<\/glossary>\n        bottom half handler is processed, along with all the other bottom half handlers,\n\twhen the scheduler next runs.\n\tThis queue should not be confused with system timers, which are a much\n\tmore sophisticated mechanism.\n\t<dt><b>immediate<\/b><\/dt><dd> This <glossary>queue<\/glossary> is also processed\n        when the scheduler processes the\n\tactive bottom half handlers.  The immediate bottom half handler is not\n\tas high in priority as the timer <glossary>queue<\/glossary> bottom half handler and so these\n\ttasks will be run later.\n\t<dt><b>scheduler<\/b><\/dt><dd> This task <glossary>queue<\/glossary> is processed directly by the scheduler.\n\tIt is used to support other task queues in the system and, in this case,\n\tthe task to be run will be a routine that processes a task queue, say\n\tfor a <glossary>device driver<\/glossary>.\n<\/dl>\n<p>\nWhen task queues are processed, the pointer to the first element in the queue is\nremoved from the <glossary>queue<\/glossary> and replaced with a null pointer.\nIn fact, this removal is an <glossary>atomic<\/glossary> operation, one that cannot be interrupted.\nThen each element in the <glossary>queue<\/glossary> has its handling routine called in turn.\nThe elements in the queue are often statically allocated data.\nHowever there is no inherent mechanism for discarding allocated memory.\nThe task <glossary>queue<\/glossary> processing routine simply moves to the next element in the list.\nIt is the job of the task itself to ensure that it properly cleans up any allocated\n<glossary>kernel<\/glossary> memory.\n","protected":false},"excerpt":{"rendered":"<p>Task Queues Figure: A Task Queue Task queues are the kernel&#8216;s way of deferring work until later. Linux queues work using a generic mechanism, so it can processes the queues later. Task queues are often used in conjunction with bottom &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=413\">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-413","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/413","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=413"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/413\/revisions"}],"predecessor-version":[{"id":725,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/413\/revisions\/725"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}