{"id":470,"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:40","modified_gmt":"2020-08-22T20:26:40","slug":"this-is-the-page-title-toplevel-303","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=470","title":{"rendered":"Times and Timers"},"content":{"rendered":"\n<title>Times and Timers<\/title>\nThe kernel keeps track of a process&#8217;s creation time as well as the\nCPU time that it consumes during its lifetime.  Each clock tick, the\nkernel updates the amount of time in <tt>jiffies<\/tt> that the current process\nhas spent in system and in user mode.\n<p>\nIn addition to these accounting timers, Linux supports process specific <em>interval<\/em> timers.\n<p>\nA process can use these timers to send itself various signals each time that\nthey expire.\nThree sorts of interval timers are supported:\n<dl compact>\n<p>\n\t<dt><b>Real<\/b><\/dt><dd> the timer ticks in real time, and when the timer has expired,\n\t\tthe process is sent a <tt>SIGALRM<\/tt> signal.\n\t<dt><b>Virtual<\/b><\/dt><dd> This timer only ticks when the process is running and when\n\t\tit expires it sends a <tt>SIGVTALRM<\/tt> signal.\n\t<dt><b>Profile<\/b><\/dt><dd> This timer ticks both when the process is running and when\n\t\tthe system is executing on behalf of the process itself.\n\t\t<tt>SIGPROF<\/tt> is signalled when it expires.\n<\/dl>\n<p>\nOne or all of the interval timers may be running and Linux keeps all of the neccessary\ninformation in the process&#8217;s <tt>task_struct<\/tt> data structure.\nSystem calls can be made to set up these interval timers and to start them, stop them\nand read their current values.\nThe virtual and profile timers are handled the same way.\n<p>\nEvery clock tick the current process&#8217;s interval timers are decremented and, if they\nhave expired, the appropriate signal is sent.\n<p>\nReal time interval timers are a little different and for these Linux uses the timer\nmechanism described <tutorial id=\"266\">elsewhere<\/a>.\nEach process has its own <tt>timer_list<\/tt> data structure and, when the real interval\ntimer is running, this is queued on the system timer list.\nWhen the timer expires the timer bottom half handler removes it from the queue and\ncalls the interval timer handler.\n<p>\nThis generates the <tt>SIGALRM<\/tt> signal and restarts the interval timer, adding it\nback into the system timer queue.\n<p>\n","protected":false},"excerpt":{"rendered":"<p>Times and Timers The kernel keeps track of a process&#8217;s creation time as well as the CPU time that it consumes during its lifetime. Each clock tick, the kernel updates the amount of time in jiffies that the current process &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=470\">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-470","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/470","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=470"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/470\/revisions"}],"predecessor-version":[{"id":766,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/470\/revisions\/766"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}