{"id":338114,"date":"2022-09-08T15:00:51","date_gmt":"2022-09-08T15:00:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=338114"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=338114","title":{"rendered":"<span>\u041f\u043e\u0441\u043e\u0431\u0438\u0435 \u043f\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 Linux. \u0427.5<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/686596\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\"\/><\/div>\n<p><\/a><br \/>  \u041f\u044f\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 \u043e\u0442 2 \u0438\u044e\u043b\u044f 2022 \u0433\u043e\u0434\u0430. \u0412 \u043d\u0435\u0439 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u0432 \u044f\u0434\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u044d\u0442\u043e\u043c \u0438\u0433\u0440\u0430\u0435\u0442 \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f (sleep), \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0438 \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<a name=\"habracut\"><\/a><\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430:<\/font><\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/681880\/\">\u0427\u0430\u0441\u0442\u044c 1<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/683106\/\">\u0427\u0430\u0441\u0442\u044c 2<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/684382\/\">\u0427\u0430\u0441\u0442\u044c 3<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/685168\/\">\u0427\u0430\u0441\u0442\u044c 4<\/a><\/li>\n<li> <b><font color=\"#3AC1EF\">\u0412\u044b \u0442\u0443\u0442 &#8212;> <\/font><\/b><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/686596\/\">\u0427\u0430\u0441\u0442\u044c 5<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">11. \u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/font><\/h2>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d 11.1 \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435<\/font><\/h3>\n<p>  \u0427\u0442\u043e \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0441 \u043f\u0440\u043e\u0441\u044f\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e, \u0447\u0435\u043c \u043f\u043e\u043a\u0430 \u0432\u044b \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435? \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0438\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0432\u044b \u043d\u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u0438\u0448\u044c: \u00ab\u042f \u043f\u043e\u043a\u0430 \u0437\u0430\u043d\u044f\u0442. \u041d\u0435 \u043c\u0435\u0448\u0430\u0439\u00bb. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0435\u0441\u044c \u044f\u0434\u0440\u043e\u043c, \u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u043a \u0432\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f (sleep), \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0442\u044c. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u044f\u0434\u0440\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0430\u0435\u0442 \u0438\u0445. \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0426\u041f\u0423.<\/p>\n<p>  \u0418 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0434\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044d\u0442\u043e\u0433\u043e. \u0424\u0430\u0439\u043b (\u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>\/proc\/sleep<\/code>) \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c. \u0415\u0441\u043b\u0438 \u043e\u043d \u0443\u0436\u0435 \u043e\u0442\u043a\u0440\u044b\u0442, \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>wait_event_interruptible<\/code>. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0444\u0430\u0439\u043b \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u2013 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">tail -f<\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u0434\u0430\u0447\u0438 (\u0437\u0430\u0434\u0430\u0447\u0430 \u2013 \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0434\u0440\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442) \u043d\u0430 <code>TASK_INTERRUPTIBLE<\/code>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043e \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0435\u0435 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f, \u0430 \u043f\u043e\u043a\u0430 \u043e\u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 <code>WaitQ<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447, \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u0443. \u0417\u0430\u0442\u0435\u043c \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0443\u0436\u0435\u043d \u0426\u041f\u0423.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c, \u043e\u043d \u0435\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442, \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>module_close<\/code>. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (\u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0445 \u043f\u043e \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0435), \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0442, \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0437\u0430\u043a\u0440\u044b\u0432\u0448\u0438\u0439 \u0444\u0430\u0439\u043b, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u0414\u0430\u043b\u0435\u0435 \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0426\u041f\u0423 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0421\u0432\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>module_interruptible_sleep_on<\/code>.<\/p>\n<p>  \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u044f\u0434\u0440\u0430 \u2013 \u043f\u043e \u0438\u043c\u0435\u044e\u0449\u0435\u0439\u0441\u044f \u0443 \u043d\u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043e\u043d \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>open()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0435\u0449\u0435 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043e\u043c \u0426\u041f\u0423 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u0435\u043c-\u0442\u043e \u0435\u0449\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u043f\u043e\u043a\u0430 \u043e\u0442\u043a\u0440\u044b\u0442, \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u041a\u043e\u0433\u0434\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u043b\u044e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0426\u041f\u0423, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u044d\u0442\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>tail -f<\/code>, \u0447\u0442\u043e\u0431\u044b \u0444\u043e\u043d\u043e\u0432\u043e \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c (\u0442\u0430\u043a\u0436\u0435 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 VT). \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0444\u043e\u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>kill %1<\/code>, \u043f\u0440\u043e\u0431\u0443\u0434\u0438\u0442\u0441\u044f \u0432\u0442\u043e\u0440\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c <code>module_close<\/code> \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u043a\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0444\u0430\u0439\u043b\u0443. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u043c <i>Ctrl+C<\/i> (<code>SIGINT<\/code>). \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0442\u043e\u043c\u0443 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>module_interruptible_sleep_on<\/code>. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c <code>module_sleep_on<\/code>, \u043d\u043e \u044d\u0442\u043e \u0431\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0437\u043b\u0438\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0447\u044c\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u044f <i>Ctrl+\u0421<\/i> \u0442\u043e\u0433\u0434\u0430 \u0431\u044b \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <code>-EINTR<\/code>. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0444\u0430\u0439\u043b\u0443.<\/p>\n<p>  \u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0438 \u0435\u0449\u0435 \u043a\u043e\u0435-\u0447\u0442\u043e. \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0435 \u0445\u043e\u0442\u044f\u0442 \u0441\u043f\u0430\u0442\u044c, \u043e\u043d\u0438 \u0445\u043e\u0442\u044f\u0442 \u043d\u0435\u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u0438\u0431\u043e \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435, \u043b\u0438\u0431\u043e \u043e\u0442\u0432\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \u0444\u043b\u0430\u0433 <code>O_NONBLOCK<\/code>. \u041d\u0430 \u044d\u0442\u043e \u044f\u0434\u0440\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438 <code>-EAGAIN<\/code> \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u0430\u0439\u043b\u0430, \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0414\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0441 <code>O_NONBLOCK<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 <code>cat_nonblock<\/code>, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <code>examples\/other<\/code>.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">sleep.ko<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">$ sudo insmod sleep.ko $ cat_nonblock \/proc\/sleep Last input: $ tail -f \/proc\/sleep &amp; Last input: Last input: Last input: Last input: Last input: Last input: Last input: tail: \/proc\/sleep: file truncated [1] 6540 $ cat_nonblock \/proc\/sleep Open would block $ kill %1 [1]+  Terminated              tail -f \/proc\/sleep $ cat_nonblock \/proc\/sleep Last input: $ \/*   * sleep.c \u2013 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \/proc, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f   * \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0432\u0441\u0435 \u0438\u0445 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435.   *\/    #include &lt;linux\/kernel.h> \/* \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044f\u0434\u0440\u043e\u043c. *\/  #include &lt;linux\/module.h> \/* \u0414\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044f. *\/  #include &lt;linux\/proc_fs.h> \/* \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f procfs *\/  #include &lt;linux\/sched.h> \/* \u0414\u043b\u044f \u0443\u0441\u044b\u043f\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u0438\u0445 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u044f. *\/   #include &lt;linux\/uaccess.h> \/* \u0414\u043b\u044f get_user \u0438 put_user. *\/  #include &lt;linux\/version.h>    #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)  #define HAVE_PROC_OPS  #endif    \/* \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c   * \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0432\u043e\u0434\u0430.   *\/  #define MESSAGE_LENGTH 80  static char message[MESSAGE_LENGTH];    static struct proc_dir_entry *our_proc_file;  #define PROC_ENTRY_FILENAME \"sleep\"    \/* \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0442\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u043c   * \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 proc \u0438 \u0434\u043e\u043b\u0436\u043d\u044b   * \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0447\u0442\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f.   *\/  static ssize_t module_output(struct file *file, \/* \u0441\u043c. include\/linux\/fs.h   *\/                               char __user *buf, \/* \u0411\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445                                           (\u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f).    *\/                                size_t len, \/* \u0414\u043b\u0438\u043d\u0430 \u0431\u0443\u0444\u0435\u0440\u0430. *\/                               loff_t *offset)  {      static int finished = 0;      int i;      char output_msg[MESSAGE_LENGTH + 30];        \/* \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c 0, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044f \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430.       *\/      if (finished) {          finished = 0;          return 0;      }        sprintf(output_msg, \"Last input:%s\\n\", message);      for (i = 0; i &lt; len &amp;&amp; output_msg[i]; i++)          put_user(output_msg[i], buf + i);        finished = 1;      return i; \/* \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u201c\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445\u201d \u0431\u0430\u0439\u0442. *\/  }    \/* \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0432\u043e\u0434 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044c  * \u0432 \u0444\u0430\u0439\u043b \/proc.   *\/  static ssize_t module_input(struct file *file, \/* \u0421\u0430\u043c \u0444\u0430\u0439\u043b. *\/                              const char __user *buf, \/* \u0411\u0443\u0444\u0435\u0440 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c. *\/                              size_t length, \/* \u0414\u043b\u0438\u043d\u0430 \u0431\u0443\u0444\u0435\u0440\u0430. *\/                              loff_t *offset) \/* C\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u2013 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f.  *\/  {      int i;        \/* \u041f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0430 \u0432 Message, \u0433\u0434\u0435 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0435\u0433\u043e \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c        * module_output.       *\/      for (i = 0; i &lt; MESSAGE_LENGTH - 1 &amp;&amp; i &lt; length; i++)          get_user(message[i], buf + i);      \/* \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0430\u044f\u0441\u044f \u043d\u0443\u043b\u0435\u043c. *\/      message[i] = '\\0';        \/* \u041d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0432\u043e\u0434\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. *\/      return i;  }    \/* 1, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0441\u0435\u0439\u0447\u0430\u0441 \u0443\u0436\u0435 \u043a\u0435\u043c-\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0442. *\/  static atomic_t already_open = ATOMIC_INIT(0);    \/* \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0444\u0430\u0439\u043b\u0443. *\/  static DECLARE_WAIT_QUEUE_HEAD(waitq);    \/* \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \/proc. *\/  static int module_open(struct inode *inode, struct file *file)  {      \/* \u0415\u0441\u043b\u0438 \u0444\u043b\u0430\u0433\u0438 \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 O_NONBLOCK, \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441       * \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0436\u0434\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b       * \u0443\u0436\u0435 \u043e\u0442\u043a\u0440\u044b\u0442, \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439       * \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c, \u0430 \u0432\u0435\u0440\u043d\u0443\u0442\u044c -EAGAIN, \u0441\u043e\u043e\u0431\u0449\u0438\u0432 \u0435\u043c\u0443,       * \u0447\u0442\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0437\u0436\u0435.      *\/      if ((file->f_flags &amp; O_NONBLOCK) &amp;&amp; atomic_read(&amp;already_open))          return -EAGAIN;        \/* \u042d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f try_module_get(THIS_MODULE), \u0442\u0430\u043a \u043a\u0430\u043a,       * \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 \u044f\u0434\u0440\u0430, \u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c       * \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f.       *\/      try_module_get(THIS_MODULE);        while (atomic_cmpxchg(&amp;already_open, 0, 1)) {          int i, is_sig = 0;            \/* \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043b\u044e\u0431\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435           * \u0432\u044b\u0437\u043e\u0432\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0448\u0438, \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435. \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443            * \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043b\u0438\u0431\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435           * wake_up(&amp;waitq) (\u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e module_close \u043f\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438            * \u0444\u0430\u0439\u043b\u0430), \u043b\u0438\u0431\u043e \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0432\u0440\u043e\u0434\u0435 Ctrl+C.          *\/          wait_event_interruptible(waitq, !atomic_read(&amp;already_open));            \/* \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0438\u0437-\u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435           * \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0432\u0435\u0440\u043d\u0443\u0442\u044c -EINTR (\u043f\u0440\u043e\u0432\u0430\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430). \u042d\u0442\u043e              * \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.           *\/          for (i = 0; i &lt; _NSIG_WORDS &amp;&amp; !is_sig; i++)              is_sig = current->pending.signal.sig[i] &amp; ~current->blocked.sig[i];            if (is_sig) {              \/* \u0412\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c module_put(THIS_MODULE) \u0441\u044e\u0434\u0430, \u0442\u0430\u043a \u043a\u0430\u043a              * \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0433\u0434\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0440\u0432\u0430\u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f open(),               * \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 close() \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u043d\u0435               * \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0434\u0435\u0441\u044c, \u0443 \u043d\u0430\u0441                * \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0447\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0438\u043a\u0430\u043a \u0443\u0436\u0435               * \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043a \u043d\u0443\u043b\u044e. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0431\u0435\u0441\u0441\u043c\u0435\u0440\u0442\u043d\u044b\u0439               * \u043c\u043e\u0434\u0443\u043b\u044c, \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430.               *\/              module_put(THIS_MODULE);              return -EINTR;          }      }        return 0; \/* \u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. *\/  }    \/* \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \/proc. *\/  static int module_close(struct inode *inode, struct file *file)  {      \/* \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c already_open \u043d\u0430 \u043d\u0443\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 waitq       * \u043c\u043e\u0433 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c already_open \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0444\u0430\u0439\u043b. \u0412 \u0438\u0442\u043e\u0433\u0435       * \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e already_open       * \u0440\u0430\u0432\u0435\u043d \u043e\u0434\u043d\u043e\u043c\u0443, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435.       *\/      atomic_set(&amp;already_open, 0);        \/* \u041f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 waitq, \u0447\u0442\u043e\u0431\u044b \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0439 \u043c\u043e\u0433       * \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u0443.       *\/      wake_up(&amp;waitq);        module_put(THIS_MODULE);        return 0; \/* \u0423\u0441\u043f\u0435\u0445. *\/  }    \/* \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0430\u0439\u043b\u0430 \/proc \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u0432\u0441\u0435   * \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.   *\/    \/* \u0424\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \/proc. \u0417\u0434\u0435\u0441\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430  * \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441   * \u0444\u0430\u0439\u043b\u043e\u043c. NULL \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.   *\/  #ifdef HAVE_PROC_OPS  static const struct proc_ops file_ops_4_our_proc_file = {      .proc_read = module_output, \/* \"\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435\" \u0438\u0437 \u0444\u0430\u0439\u043b\u0430. *\/      .proc_write = module_input, \/* \"\u0417\u0430\u043f\u0438\u0441\u044c\" \u0432 \u0444\u0430\u0439\u043b. *\/      .proc_open = module_open, \/* \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \/proc *\/      .proc_release = module_close, \/* \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0435\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438. *\/  };  #else  static const struct file_operations file_ops_4_our_proc_file = {      .read = module_output,      .write = module_input,      .open = module_open,      .release = module_close,  };  #endif    \/* \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u2013 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \/proc. *\/  static int __init sleep_init(void)  {      our_proc_file =          proc_create(PROC_ENTRY_FILENAME, 0644, NULL, &amp;file_ops_4_our_proc_file);      if (our_proc_file == NULL) {          remove_proc_entry(PROC_ENTRY_FILENAME, NULL);          pr_debug(\"Error: Could not initialize \/proc\/%s\\n\", PROC_ENTRY_FILENAME);          return -ENOMEM;      }      proc_set_size(our_proc_file, 80);      proc_set_user(our_proc_file, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID);        pr_info(\"\/proc\/%s created\\n\", PROC_ENTRY_FILENAME);        return 0;  }    \/* \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u2013 \u0441\u043d\u044f\u0442\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \/proc.  \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0430\u0441\u043d\u043e,    * \u0435\u0441\u043b\u0438 \u0432 waitq \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f   * \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 open(), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u0430. \u0412 10 \u0433\u043b\u0430\u0432\u0435 \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e,   * \u043a\u0430\u043a \u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f.   *\/  static void __exit sleep_exit(void)  {      remove_proc_entry(PROC_ENTRY_FILENAME, NULL);      pr_debug(\"\/proc\/%s removed\\n\", PROC_ENTRY_FILENAME);  }    module_init(sleep_init);  module_exit(sleep_exit);  <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">cat_nonblock.c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">MODULE_LICENSE(\"GPL\"); \/*   *  cat_nonblock.c \u2013 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435, \u043d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435   *  \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442.   *\/  #include &lt;errno.h> \/* \u0414\u043b\u044f errno. *\/  #include &lt;fcntl.h> \/* \u0414\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f. *\/  #include &lt;stdio.h> \/* \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434. *\/  #include &lt;stdlib.h> \/* \u0414\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u0430. *\/  #include &lt;unistd.h> \/* \u0414\u043b\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f.*\/    #define MAX_BYTES 1024 * 4    int main(int argc, char *argv[])  {      int fd; \/* \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. *\/      size_t bytes; \/* \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0431\u0430\u0439\u0442. *\/      char buffer[MAX_BYTES]; \/* \u0411\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0431\u0430\u0439\u0442. *\/        \/* \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. *\/      if (argc != 2) {          printf(\"Usage: %s &lt;filename>\\n\", argv[0]);          puts(\"Reads the content of a file, but doesn't wait for input\");          exit(-1);      }        \/* \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c\u0441\u044f \u0440\u0435\u0436\u0438\u043c\u0435. *\/      fd = open(argv[1], O_RDONLY | O_NONBLOCK);        \/* \u0415\u0441\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u043e\u0441\u044c. *\/      if (fd == -1) {          puts(errno == EAGAIN ? \"Open would block\" : \"Open failed\");          exit(-1);      }        \/* \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e. *\/      do {          \/* \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430. *\/          bytes = read(fd, buffer, MAX_BYTES);            \/* \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e \u043d\u0435\u0439 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f. *\/          if (bytes == -1) {              if (errno == EAGAIN)                  puts(\"Normally I'd block, but you told me not to\");              else                  puts(\"Another read error\");              exit(-1);          }            \/* \u0412\u044b\u0432\u043e\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. *\/          if (bytes > 0) {              for (int i = 0; i &lt; bytes; i++)                  putchar(buffer[i]);          }            \/* \u041f\u043e\u043a\u0430 \u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043e\u043a, \u0438 \u0444\u0430\u0439\u043b \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0441\u044f. *\/      } while (bytes > 0);        return 0;  }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d 11.2 \u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/font><\/h3>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435, \u0438\u043c\u0435\u044e\u0449\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043e\u0434\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0434\u0440\u0443\u0433\u0438\u043c. \u0418 \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 <code>\/bin\/sleep<\/code> \u044f\u0434\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u043c \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b \u0438\u043b\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430, \u043d\u043e \u043e\u0434\u0438\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">completion.c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/*   * completions.c   *\/  #include &lt;linux\/completion.h>  #include &lt;linux\/init.h>  #include &lt;linux\/kernel.h>  #include &lt;linux\/kthread.h>  #include &lt;linux\/module.h>    static struct {      struct completion crank_comp;      struct completion flywheel_comp;  } machine;    static int machine_crank_thread(void *arg)  {      pr_info(\"Turn the crank\\n\");        complete_all(&amp;machine.crank_comp);      complete_and_exit(&amp;machine.crank_comp, 0);  }    static int machine_flywheel_spinup_thread(void *arg)  {      wait_for_completion(&amp;machine.crank_comp);        pr_info(\"Flywheel spins up\\n\");        complete_all(&amp;machine.flywheel_comp);      complete_and_exit(&amp;machine.flywheel_comp, 0);  }    static int completions_init(void)  {      struct task_struct *crank_thread;      struct task_struct *flywheel_thread;        pr_info(\"completions example\\n\");        init_completion(&amp;machine.crank_comp);      init_completion(&amp;machine.flywheel_comp);        crank_thread = kthread_create(machine_crank_thread, NULL, \"KThread Crank\");      if (IS_ERR(crank_thread))          goto ERROR_THREAD_1;        flywheel_thread = kthread_create(machine_flywheel_spinup_thread, NULL,                                       \"KThread Flywheel\");      if (IS_ERR(flywheel_thread))          goto ERROR_THREAD_2;        wake_up_process(flywheel_thread);      wake_up_process(crank_thread);        return 0;    ERROR_THREAD_2:      kthread_stop(crank_thread);  ERROR_THREAD_1:        return -1;  }    static void completions_exit(void)  {      wait_for_completion(&amp;machine.crank_comp);      wait_for_completion(&amp;machine.flywheel_comp);        pr_info(\"completions exit\\n\");  }    module_init(completions_init);  module_exit(completions_exit);    MODULE_DESCRIPTION(\"Completions example\");  MODULE_LICENSE(\"GPL\");<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <code>machine<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0412 \u0442\u043e\u0447\u043a\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u0430 <code>flywheel<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>wait_for_completion<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f \u043f\u0440\u0435\u0436\u0434\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u0422\u0430\u043a \u0447\u0442\u043e, \u0445\u043e\u0442\u044c <code>flywheel_thread<\/code> \u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u043c, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0432 \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 <code>dmesg<\/code>, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0440\u044b\u0447\u0430\u0433\u0430 (<code>crank<\/code>), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0442\u043e\u043a \u043c\u0430\u0445\u043e\u0432\u0438\u043a\u0430 (<code>flywheel<\/code>) \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0435\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f. <\/p>\n<p>  \u0423 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>wait_for_completion<\/code> \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u0431\u0435\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h2><font color=\"#3AC1EF\">12. \u0418\u0437\u0431\u0435\u0433\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0438 \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a<\/font><\/h2>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 \u0438\u043b\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0438, \u043b\u0438\u0431\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u0414\u043b\u044f \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u044f\u0434\u0440\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f (\u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b). \u041e\u043d\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u00ab\u0437\u0430\u043d\u044f\u0442\u00bb \u0438\u043b\u0438 \u00ab\u0441\u0432\u043e\u0431\u043e\u0434\u0435\u043d\u00bb \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. <\/p>\n<h3><font color=\"#3AC1EF\">\u258d 12.1 \u041c\u044c\u044e\u0442\u0435\u043a\u0441\u044b<\/font><\/h3>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b \u044f\u0434\u0440\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0435. \u0418 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0434\u043b\u044f \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u044d\u0442\u043e\u0433\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">example_mutex.c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/*   * example_mutex.c   *\/  #include &lt;linux\/init.h>  #include &lt;linux\/kernel.h>  #include &lt;linux\/module.h>  #include &lt;linux\/mutex.h>    static DEFINE_MUTEX(mymutex);    static int example_mutex_init(void)  {      int ret;        pr_info(\"example_mutex init\\n\");        ret = mutex_trylock(&amp;mymutex);      if (ret != 0) {          pr_info(\"mutex is locked\\n\");            if (mutex_is_locked(&amp;mymutex) == 0)              pr_info(\"The mutex failed to lock!\\n\");            mutex_unlock(&amp;mymutex);          pr_info(\"mutex is unlocked\\n\");      } else          pr_info(\"Failed to lock\\n\");        return 0;  }    static void example_mutex_exit(void)  {      pr_info(\"example_mutex exit\\n\");  }    module_init(example_mutex_init);  module_exit(example_mutex_exit);    MODULE_DESCRIPTION(\"Mutex example\");  MODULE_LICENSE(\"GPL\");<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d 12.2 \u0421\u043f\u0438\u043d-\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438<\/font><\/h3>\n<p>  \u0421\u043f\u0438\u043d-\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0438\u043b\u0438 \u0441\u043f\u0438\u043d\u043b\u043e\u043a\u0438, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u0426\u041f\u0423, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0434, \u0437\u0430\u043d\u0438\u043c\u0430\u044f 100% \u0435\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043f\u0438\u043d\u043b\u043e\u043a\u043e\u0432 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u0434\u0430, \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434, \u0447\u0442\u043e\u0431\u044b \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f <i>irq safe<\/i>, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0435\u0435 \u0441\u043d\u044f\u0442\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>flags<\/code> \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">example_spinlock.c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/*   * example_spinlock.c   *\/  #include &lt;linux\/init.h>  #include &lt;linux\/interrupt.h>  #include &lt;linux\/kernel.h>  #include &lt;linux\/module.h>  #include &lt;linux\/spinlock.h>    static DEFINE_SPINLOCK(sl_static);  static spinlock_t sl_dynamic;    static void example_spinlock_static(void)  {      unsigned long flags;        spin_lock_irqsave(&amp;sl_static, flags);      pr_info(\"Locked static spinlock\\n\");        \/* \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f 100% \u0426\u041f\u0423,        * \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.       *\/        spin_unlock_irqrestore(&amp;sl_static, flags);      pr_info(\"Unlocked static spinlock\\n\");  }    static void example_spinlock_dynamic(void)  {      unsigned long flags;        spin_lock_init(&amp;sl_dynamic);      spin_lock_irqsave(&amp;sl_dynamic, flags);      pr_info(\"Locked dynamic spinlock\\n\");        \/* \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f 100% \u0426\u041f\u0423,       * \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434.       *\/        spin_unlock_irqrestore(&amp;sl_dynamic, flags);      pr_info(\"Unlocked dynamic spinlock\\n\");  }    static int example_spinlock_init(void)  {      pr_info(\"example spinlock started\\n\");        example_spinlock_static();      example_spinlock_dynamic();        return 0;  }    static void example_spinlock_exit(void)  {      pr_info(\"example spinlock exit\\n\");  }    module_init(example_spinlock_init);  module_exit(example_spinlock_exit);    MODULE_DESCRIPTION(\"Spinlock example\");  MODULE_LICENSE(\"GPL\");<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d 12.3 \u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438<\/font><\/h3>\n<p>  \u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u2013 \u044d\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043b\u043e\u043a\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c. \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e <i>irq safe<\/i>, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u0430\u043c \u0447\u0442\u0435\u043d\u0438\u0435\/\u0437\u0430\u043f\u0438\u0441\u044c, \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u0434\u043b\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u0434\u0432\u0435\u0448\u0438\u0432\u0430\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438 \u043d\u0435\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0438\u0440\u0430\u043d\u0438\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">example_rwlock.c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/*   * example_rwlock.c   *\/  #include &lt;linux\/interrupt.h>  #include &lt;linux\/kernel.h>  #include &lt;linux\/module.h>    static DEFINE_RWLOCK(myrwlock);    static void example_read_lock(void)  {      unsigned long flags;        read_lock_irqsave(&amp;myrwlock, flags);      pr_info(\"Read Locked\\n\");       \/* \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435. *\/        read_unlock_irqrestore(&amp;myrwlock, flags);      pr_info(\"Read Unlocked\\n\");  }    static void example_write_lock(void)  {      unsigned long flags;        write_lock_irqsave(&amp;myrwlock, flags);      pr_info(\"Write Locked\\n\");        \/* \u0417\u0430\u043f\u0438\u0441\u044c. *\/        write_unlock_irqrestore(&amp;myrwlock, flags);      pr_info(\"Write Unlocked\\n\");  }    static int example_rwlock_init(void)  {      pr_info(\"example_rwlock started\\n\");        example_read_lock();      example_write_lock();        return 0;  }    static void example_rwlock_exit(void)  {      pr_info(\"example_rwlock exit\\n\");  }    module_init(example_rwlock_init);  module_exit(example_rwlock_exit);    MODULE_DESCRIPTION(\"Read\/Write locks example\");  MODULE_LICENSE(\"GPL\");<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u044e\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 <code>read_lock(&amp;myrwlock)<\/code> \u0438 <code>read_unlock(&amp;myrwlock)<\/code> \u043b\u0438\u0431\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d 12.4 \u0410\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/font><\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0443: \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u043c\u0438\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u043c\u0435\u0448\u0430\u0442\u044c\u0441\u044f \u0432 \u0432\u0430\u0448\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u043e. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448\u0435 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u0430\u043a\u0438\u043c\u0438-\u043b\u0438\u0431\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">example_atomic.c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/*   * example_atomic.c   *\/  #include &lt;linux\/interrupt.h>  #include &lt;linux\/kernel.h>  #include &lt;linux\/module.h>    #define BYTE_TO_BINARY_PATTERN \"%c%c%c%c%c%c%c%c\"  #define BYTE_TO_BINARY(byte)                                                   \\      ((byte &amp; 0x80) ? '1' : '0'), ((byte &amp; 0x40) ? '1' : '0'),                  \\          ((byte &amp; 0x20) ? '1' : '0'), ((byte &amp; 0x10) ? '1' : '0'),              \\          ((byte &amp; 0x08) ? '1' : '0'), ((byte &amp; 0x04) ? '1' : '0'),              \\          ((byte &amp; 0x02) ? '1' : '0'), ((byte &amp; 0x01) ? '1' : '0')    static void atomic_add_subtract(void)  {      atomic_t debbie;      atomic_t chris = ATOMIC_INIT(50);        atomic_set(&amp;debbie, 45);        \/* \u0412\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b. *\/      atomic_dec(&amp;debbie);        atomic_add(7, &amp;debbie);        \/* \u041f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b. *\/      atomic_inc(&amp;debbie);        pr_info(\"chris: %d, debbie: %d\\n\", atomic_read(&amp;chris),              atomic_read(&amp;debbie));  }    static void atomic_bitwise(void)  {      unsigned long word = 0;        pr_info(\"Bits 0: \" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));      set_bit(3, &amp;word);      set_bit(5, &amp;word);      pr_info(\"Bits 1: \" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));      clear_bit(5, &amp;word);      pr_info(\"Bits 2: \" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));      change_bit(3, &amp;word);        pr_info(\"Bits 3: \" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));      if (test_and_set_bit(3, &amp;word))          pr_info(\"wrong\\n\");      pr_info(\"Bits 4: \" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));        word = 255;      pr_info(\"Bits 5: \" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));  }    static int example_atomic_init(void)  {      pr_info(\"example_atomic started\\n\");        atomic_add_subtract();      atomic_bitwise();        return 0;  }    static void example_atomic_exit(void)  {      pr_info(\"example_atomic exit\\n\");  }    module_init(example_atomic_init);  module_exit(example_atomic_exit);    MODULE_DESCRIPTION(\"Atomic operations example\");  MODULE_LICENSE(\"GPL\");<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0414\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u042111 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u044f\u0434\u0440\u043e \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0445 \u043d\u0430\u0431\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0445\u0438\u0442\u0440\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0436\u0435 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432 \u042111 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044f\u0434\u0440\u0443 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u044d\u0442\u0438\u0445 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u0441\u0434\u0435\u043b\u0430\u0432 \u0435\u0433\u043e \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0432\u043d\u044f\u0442\u043d\u044b\u043c \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442. \u041d\u043e \u0435\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0438 \u043a\u043e\u0435-\u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0430\u043c\u044f\u0442\u0438 \u044f\u0434\u0440\u0430 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0432 \u042111. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u044d\u0442\u0430 \u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.kernel.org\/doc\/Documentation\/atomic_t.txt\">Kernel documentation of atomic types<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/691128\/\">Time to move to C11 atomics?<\/a><\/li>\n<li><a href=\"https:\/\/lwn.net\/Articles\/698315\/\">Atomic usage patterns in the kernel<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0437\u0430\u043c\u0435\u043d\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <code>print<\/code>, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0438\u0433\u0430\u044e\u0449\u0438\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430:<\/font><\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/681880\/\">\u0427\u0430\u0441\u0442\u044c 1<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/683106\/\">\u0427\u0430\u0441\u0442\u044c 2<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/684382\/\">\u0427\u0430\u0441\u0442\u044c 3<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/685168\/\">\u0427\u0430\u0441\u0442\u044c 4<\/a><\/li>\n<li> <b><font color=\"#3AC1EF\">\u0412\u044b \u0442\u0443\u0442 &#8212;> <\/font><\/b><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/686596\/\">\u0427\u0430\u0441\u0442\u044c 5<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/bit.ly\/3bDQroY\">\u041a\u043e\u043d\u043a\u0443\u0440\u0441 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0442 RUVDS.COM<\/a>. \u0422\u0440\u0438 \u0434\u0435\u043d\u0435\u0436\u043d\u044b\u0435 \u043d\u043e\u043c\u0438\u043d\u0430\u0446\u0438\u0438. \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u0440\u0438\u0437 \u2014 100 000 \u0440\u0443\u0431\u043b\u0435\u0439. <\/font><\/b><\/p><\/blockquote>\n<p><a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=Bright_Translate&amp;utm_content=posobie_po_programmirovaniyu_modulej_yadra_linux._ch.5\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sz\/7j\/pf\/sz7jpfj8i1pa6ocj-eia09dev4q.png\" data-src=\"https:\/\/habrastorage.org\/webt\/sz\/7j\/pf\/sz7jpfj8i1pa6ocj-eia09dev4q.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/686596\/\"> https:\/\/habr.com\/ru\/company\/ruvds\/blog\/686596\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/686596\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-7\/yl\/hp\/-7ylhpzc6raohz-vopxottyejfu.png\"\/><\/div>\n<p><\/a><br \/>  \u041f\u044f\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0434\u0440\u0430 \u043e\u0442 2 \u0438\u044e\u043b\u044f 2022 \u0433\u043e\u0434\u0430. \u0412 \u043d\u0435\u0439 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u0432 \u044f\u0434\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u044d\u0442\u043e\u043c \u0438\u0433\u0440\u0430\u0435\u0442 \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f (sleep), \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0438 \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-338114","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=338114"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338114\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}