{"id":177369,"date":"2013-04-20T15:53:02","date_gmt":"2013-04-20T11:53:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=177369"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=177369","title":{"rendered":"<span class=\"post_title\">\u041e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043f\u043e\u0434\u043c\u0435\u043d\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0425\u0430\u0431\u0440\u0430\u044e\u0437\u0435\u0440\u044b!<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u0440\u0435\u0448\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpthread. \u0422\u0430\u043a\u0430\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0443 \u043d\u0430\u0441 \u0432 \u0445\u043e\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u2014 <a href=\"http:\/\/habrahabr.ru\/company\/nordavind\/blog\/176541\/\">habrahabr.ru\/company\/nordavind\/blog\/176541\/<\/a>. \u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043f\u0435\u0448\u0438\u043c \u0435\u0439 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0425\u0430\u0431\u0440\u0430\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u041d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0448\u0430\u043b\u0438 \u043c\u044b. \u0414\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0432 \u043d\u0435\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u00bb \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 libpthread. \u0422.\u0435. \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u043e\u0434\u043c\u0435\u043d\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpthread \u043d\u0430 \u043d\u0435\u043a\u0443\u044e \u043d\u0430\u0448\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 libpthreadWrapper, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 (pthread_mutex_lock, pthread_mutex_unlock, pthread_cond_signal, \u0438 \u0434\u0440.) \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e listener-\u0430 \u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0432\u044b\u0437\u043e\u0432\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0441\u0435\u0445 \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 libpthreadWrapper \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 libpthread.<a name=\"habracut\"><\/a><\/p>\n<p>  \u0412\u0441\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 pthread.h \u043c\u044b \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0442\u043d\u0438 \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0443 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0430. \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u0435\u043b bash \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0432\u0435\u043b\u043e\u0441\u044c \u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 (\u0441\u043a\u0440\u0438\u043f\u0442 \u043c\u044b, \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0434\u0435\u043b\u043e, \u043d\u0430\u0437\u0432\u0430\u043b\u0438 generate) \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 \u0421\u0438 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpthread \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043d\u0430\u0448\u0435\u043c libpthread:<\/p>\n<pre><code class=\"bash\">#! \/bin\/bash fnnames=(`sed -rne 's\/^extern .* (pthread_[a-zA-Z_0-9]+) \\(.*\/\\1\/p' \/usr\/include\/pthread.h | sort -u`) <\/code><\/pre>\n<p>  \u041f\u043e\u0442\u043e\u043c \u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c\u0438. \u0412\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u043d\u0430\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 libpthread (\u044d\u0442\u043e \u044f \u043f\u0440\u043e handle) \u0438 \u0441 \u043d\u0430\u0448\u0438\u043c \u0432\u043d\u0435\u0448\u043d\u0438\u043c listener-\u043e\u043c (\u044d\u0442\u043e \u044f \u043f\u0440\u043e serv \u0438 sock):  <\/p>\n<pre><code class=\"bash\">( cat &lt;&lt;EOF #include &lt;dlfcn.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;unistd.h&gt; #include &lt;string.h&gt; #include &lt;stdarg.h&gt; #include &lt;errno.h&gt;  #include &lt;netinet\/in.h&gt; #include &lt;netdb.h&gt; #include &lt;sys\/socket.h&gt; #include &lt;netinet\/in.h&gt; #include &lt;arpa\/inet.h&gt;  #define PORT 11111 static void *handle; static struct sockaddr_in serv; static int sock=-1;  EOF <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpthread:  <\/p>\n<pre><code class=\"bash\">for fn in ${fnnames[*]} do     echo &quot;static int (*${fn}_orig_ptr)();&quot; done  cat &lt;&lt;EOF <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u043d\u0430\u043c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 libpthread \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c __libpthread_send_notification, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e (\u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0435\u043c \u0438 \u043a\u0430\u043a) udp \u0434\u0435\u0439\u0442\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 (\u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0435\u043c \u0438 \u043a\u0430\u043a) \u0441\u043e\u043a\u0435\u0442:  <\/p>\n<pre><code class=\"bash\">__attribute__((visibility(&quot;hidden&quot;))) void __libpthread_send_notification(     const char   *name,     const char   *fmt,     ...) {     if(sock&gt;=0)     {         char buffer[1000];         unsigned int l;         int rc;          pthread_t self=pthread_self_orig_ptr();          l=snprintf(buffer, sizeof(buffer)-1, &quot;%s@%X:&quot;, name, (unsigned int)self);          va_list ap;         va_start(ap, fmt);         l+=vsnprintf(buffer+l, sizeof(buffer)-l-1, fmt, ap);         buffer[l]=0;         va_end(ap);          rc=send(sock, buffer, l+1, MSG_NOSIGNAL);         if(rc&lt;0)             fprintf(stderr, &quot;Failed to send %s\\n&quot;, strerror(errno));         else             fprintf(stderr, &quot;rc=%d\\n&quot;, rc);     } } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u043c \u043d\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0447\u0443\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u043a\u0435\u043c \u0438 \u043a\u0430\u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c?\u00bb. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 constructor \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 __libpthread_safety_init, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpthreadWrapper:  <\/p>\n<pre><code class=\"bash\">__attribute__((constructor)) void __libpthread_safety_init(void) { <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u0438\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 __libpthread_safety_init, \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430\u0448\u0435\u0433\u043e listener-\u0430 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f PTHREAD_ACTIONS_RECEIVER:  <\/p>\n<pre><code class=\"bash\">    char *ipaddr=getenv(&quot;PTHREAD_ACTIONS_RECEIVER&quot;);      memset(&serv, 0, sizeof(serv));     serv.sin_port=htons(PORT);      if(ipaddr!=NULL)     {         if(!inet_aton(ipaddr, &serv.sin_addr))         {             struct hostent *hp=gethostbyaddr(ipaddr, strlen(ipaddr), AF_INET);             if(hp==(struct hostent *)0)             {                 serv.sin_addr.s_addr=htonl(INADDR_LOOPBACK);             }             else             {                 serv.sin_addr=*(struct in_addr *)hp-&gt;h_addr;             }         }     }     else     {         serv.sin_addr.s_addr=htonl(INADDR_LOOPBACK);     }      if((sock=socket(AF_INET, SOCK_STREAM, 0))&lt;0)     {         fprintf(stderr, &quot;Failed to create socket\\n&quot;);     }     else if(connect(sock, (struct sockaddr *)&serv, sizeof(serv))&lt;0)     {         fprintf(stderr, &quot;Failed to connect\\n&quot;);         close(sock);         sock=-1;     } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 listener-\u0443, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 libpthread, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c dlopen-\u043e\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0432\u0441\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"bash\">    handle=dlopen(&quot;\/lib\/libpthread.so.0&quot;, RTLD_NOW);      fprintf(stderr, &quot;dlopened original libpthread, handle=%p\\n&quot;, handle); EOF  for fn in ${fnnames[*]} do     echo &quot;    ${fn}_orig_ptr=dlsym(handle, \\&quot;${fn}\\&quot;);&quot; #    echo &quot;    printf(\\&quot;%s=%p\\n\\&quot;, \\&quot;${fn}_orig_ptr\\&quot;, ${fn}_orig_ptr);&quot; done  cat &lt;&lt;EOF } <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442 \u0441\u043e\u043a\u0435\u0442 \u043f\u0440\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438. \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 destructor:  <\/p>\n<pre><code class=\"bash\">__attribute__((destructor)) void __libpthread_safety_done(void) {     close(sock); } EOF <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435! \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430\u0448\u0438\u0445 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 libpthread! \u041f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e \u0443\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u043d\u0435\u0435 \u0441\u043f\u0438\u0441\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:  <\/p>\n<pre><code class=\"bash\">for fn in ${fnnames[*]} do <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0438\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435). \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u0438\u043a \u0435\u0441\u0442\u044c, \u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0435\u0440\u0442\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 __libpthread_send_notification, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 libpthread:  <\/p>\n<pre><code class=\"bash\">    if [[ -f &quot;$0.$fn&quot; ]]     then         source &quot;$0.$fn&quot;          cat &lt;&lt;EOF extern int ${fn}($WRAPPER_ARGS) {     __libpthread_send_notification(&quot;${fn}&quot;, $FORMAT_STRING);     return ${fn}_orig_ptr($DELEGATED_ARGS); } EOF <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0438\u043a\u0430 \u043d\u0435\u0442, \u0442\u043e \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 libpthread:  <\/p>\n<pre><code class=\"bash\">    else         cat &lt;&lt;EOF extern int ${fn}() { #ifdef __x86_64__     asm(         &quot;popq %%rbp\\n\\t&quot;         &quot;movq %0,%%rax\\n\\t&quot;         &quot;jmp *%%rax\\n\\t&quot;         : \/**\/         : &quot;ri&quot;(${fn}_orig_ptr)); #else     asm(         &quot;popl %%ebp\\n\\t&quot;         &quot;movl %0,%%eax\\n\\t&quot;         &quot;jmp *%%eax\\n\\t&quot;         : \/**\/         : &quot;ri&quot;(${fn}_orig_ptr)         : &quot;eax&quot;); #endif     return 666; } EOF     fi done <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f portable, \u043d\u043e \u043e\u043d \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0432\u0430\u043c\u0438 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0438\u0437\u0430\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430.<\/p>\n<p>  \u041d\u0443 \u0438, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a:  <\/p>\n<pre><code class=\"bash\">) | tee .autogenerated | gcc -x c -fPIC -shared -Wl,-soname -Wl,libpthread.so.0 -Wall -ldl -o libpthread.so.0 - <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0441\u0430\u043c\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. \u041f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 libpthread. \u0424\u043e\u0440\u043c\u0430\u0442 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435:<\/p>\n<p>  generate.pthread_mutex_lock:  <\/p>\n<pre><code class=\"bash\">WRAPPER_ARGS=&quot;void *ptr&quot; DELEGATED_ARGS=&quot;ptr&quot; FORMAT_STRING=&quot;\\&quot;%p\\&quot;, ptr&quot; <\/code><\/pre>\n<p>  generate.pthread_mutex_unlock:  <\/p>\n<pre><code class=\"bash\">WRAPPER_ARGS=&quot;void *ptr&quot; DELEGATED_ARGS=&quot;ptr&quot; FORMAT_STRING=&quot;\\&quot;%p\\&quot;, ptr&quot; <\/code><\/pre>\n<p>  generate.pthread_cond_wait:  <\/p>\n<pre><code class=\"bash\">WRAPPER_ARGS=&quot;void *cond, void *mutex&quot; DELEGATED_ARGS=&quot;cond, mutex&quot; FORMAT_STRING=&quot;\\&quot;%p,%p\\&quot;, cond, mutex&quot; <\/code><\/pre>\n<p>  \u0418 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0432\u0430\u0448\u0438\u0445 \u0437\u0430\u0434\u0430\u0447!    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/nordavind\/blog\/177369\/\"> http:\/\/habrahabr.ru\/company\/nordavind\/blog\/177369\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0425\u0430\u0431\u0440\u0430\u044e\u0437\u0435\u0440\u044b!<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u0440\u0435\u0448\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpthread. \u0422\u0430\u043a\u0430\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0443 \u043d\u0430\u0441 \u0432 \u0445\u043e\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u2014 <a href=\"http:\/\/habrahabr.ru\/company\/nordavind\/blog\/176541\/\">habrahabr.ru\/company\/nordavind\/blog\/176541\/<\/a>. \u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043f\u0435\u0448\u0438\u043c \u0435\u0439 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0425\u0430\u0431\u0440\u0430\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u041d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0448\u0430\u043b\u0438 \u043c\u044b. \u0414\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0432 \u043d\u0435\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u00bb \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 libpthread. \u0422.\u0435. \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u043e\u0434\u043c\u0435\u043d\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpthread \u043d\u0430 \u043d\u0435\u043a\u0443\u044e \u043d\u0430\u0448\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 libpthreadWrapper, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 (pthread_mutex_lock, pthread_mutex_unlock, pthread_cond_signal, \u0438 \u0434\u0440.) \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e listener-\u0430 \u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0432\u044b\u0437\u043e\u0432\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0441\u0435\u0445 \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 libpthreadWrapper \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 libpthread.<\/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-177369","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/177369","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=177369"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/177369\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}