{"id":344487,"date":"2023-01-26T03:00:35","date_gmt":"2023-01-26T03:00:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=344487"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=344487","title":{"rendered":"<span>\u041f\u0440\u043e\u0441\u0442\u043e \u043e RCU (Read\u2013Copy-Update)<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>Lock-free \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0435, \u043d\u043e \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0432\u044b\u0441\u043e\u043a.  \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0435\u0439\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c  RCU (Read\u2013Copy-Update). \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c. <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Read-copy-update\" rel=\"noopener noreferrer nofollow\">Wikipedia<\/a>.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/liburcu.org\/\" rel=\"noopener noreferrer nofollow\">liburcu<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0448\u0442\u0430\u0442\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Ubuntu.  <\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/github.com\/vic-35\/test_liburcu\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/vic-35\/test_liburcu<\/a> , \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0432 QT creator \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430. <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f RCU \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0443\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 RCU \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u0438\u0442\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f rcu_register_thread() \u0438 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 rcu_unregister_thread(). <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 , \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c SpinLock \u0438 RCU. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0438\u0442\u0435\u0439 , \u043e\u0434\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f , \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e  \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435  \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0420\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0436\u0434\u0435\u0442 10 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043c\u044c\u044e\u0442\u0435\u043a\u0441 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0438\u0442\u0435\u0439. \u0412 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435 \u0432\u0438\u0434\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u043d\u0438\u0442\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>SpinLock \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435-\u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0432 SpinLock, \u0432 \u043e\u0434\u043d\u0443 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a  \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439  result.<\/p>\n<pre><code class=\"cpp\">    while (pthread_mutex_trylock(&amp;m1) == EBUSY) {         pthread_spin_lock(&amp;s1);         usleep(1);         if (i == 0) {             unsigned int rez = *result;             *result = 0x0;             free(result);             result = malloc(sizeof(unsigned int));             if (rez == REZ1) {                 *result = REZ2;                 count++;             } else {                 *result = REZ1;                 count1++;             }         } else {             unsigned int rez = *result;             if (rez != REZ1 &amp;&amp; rez != REZ2) {                 printf(\"Fatal error :%lld :%lld :%lld\\n\", i, count, count1);                 exit(-1);             }             if (rez == REZ1) {                 count++;             } else {                 count1++;             }         }         pthread_spin_unlock(&amp;s1);     } <\/code><\/pre>\n<p>RCU \u0432\u0435\u0440\u0441\u0438\u044f \u0442\u0430\u043a\u0436\u0435  \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430. \u041f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c  \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432  rcu_read_lock(), \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e rcu_read_unlock(). \u041c\u0435\u0436\u0434\u0443 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043d\u0438\u0442\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e *result , \u043d\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u043c rcu_xchg_pointer(&amp;result, new_result), \u0430 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0443 \u0432\u0441\u0435\u0445 \u043d\u0438\u0442\u0435\u0439, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 rcu_read_lock \u0441\u0435\u043a\u0446\u0438\u0438 , \u0444\u0443\u043d\u043a\u0446\u0438\u044f synchronize_rcu(). <\/p>\n<pre><code class=\"cpp\">    while (pthread_mutex_trylock(&amp;m1) == EBUSY) {         rcu_read_lock();         usleep(1);         if (i == 0) {             unsigned int rez = *result;             unsigned int *new_result = malloc(sizeof(unsigned int));             if (rez == REZ1) {                 *new_result = REZ2;                 count++;             } else {                 *new_result = REZ1;                 count1++;             }             rcu_read_unlock();              unsigned int *old_result = rcu_xchg_pointer(&amp;result, new_result);             synchronize_rcu();              if (old_result)                 *old_result = 0;             free(old_result);          } else {             unsigned int rez = *result;             if (rez != REZ1 &amp;&amp; rez != REZ2) {                 printf(\"Fatal error :%lld :%lld :%lld\\n\", i, count, count1);                 exit(-1);             }             if (rez == REZ1) {                 count++;              } else {                 count1++;             }             rcu_read_unlock();         }     } <\/code><\/pre>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f SpinLock \u0437\u0430\u0442\u0435\u043c RCU.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043e\u0434\u043d\u043e\u0439 \u043d\u0438\u0442\u0438 , \u0435\u0441\u0442\u044c \u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 SpinLock \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0446\u0438\u043a\u043b\u043e\u0432 \u0447\u0442\u0435\u043d\u0438\u044f &#8212; \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<blockquote>\n<p>start :0<br \/>end :0 :86325 :86324<br \/>start :0<br \/>end :0 :84708 :84708<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043d\u0438\u0442\u0435\u0439. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 SpinLock \u0440\u0435\u0437\u043a\u043e \u0441\u0434\u0430\u0435\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438\u0442\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0436\u0434\u0443\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0443.<\/p>\n<blockquote>\n<p> start :0<br \/> start :1<br \/> start :5<br \/> start :4<br \/> start :2<br \/> start :3<br \/> end :2 :17574 :24472<br \/> end :4 :1773 :2824<br \/> end :0 :3639 :3638<br \/> end :1 :16770 :16452<br \/> end :5 :21121 :32123<br \/> end :3 :18075 :22640<br \/> start :0<br \/> start :3<br \/> start :2<br \/> start :5<br \/> start :4<br \/> start :1<br \/> end :5 :85755 :85766<br \/> end :3 :86214 :86157<br \/> end :2 :86143 :86066<br \/> end :4 :85594 :85790<br \/> end :0 :41820 :41820<br \/> end :1 :85583 :85670<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435. \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u044b pthread_spin_lock(&amp;s1) \u0438 pthread_spin_unlock(&amp;s1). \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438, \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.  <\/p>\n<blockquote>\n<p>start :0<br \/> start :1<br \/> start :2<br \/> start :4<br \/> start :5<br \/> start :3<br \/> Fatal error :4 :18 :18<\/p>\n<\/blockquote>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f  \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 Lock-free \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440. \u0422\u0435\u0441\u0442 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439,  \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438  \u043d\u0438\u0442\u0438 \u043d\u0435 \u0441\u0442\u043e\u044f\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443 \u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e.  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e synchronize_rcu \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 rcu_read_lock \u0441\u0435\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 rcu_read_lock \u0441\u0435\u043a\u0446\u0438\u0438  \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432,  \u043e\u043d \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u0435\u043d \u0438 \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430. <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 liburcu. <\/p>\n<p><a href=\"https:\/\/liburcu.org\/\" rel=\"noopener noreferrer nofollow\">https:\/\/liburcu.org\/<\/a> <\/p>\n<p><a href=\"https:\/\/lwn.net\/Articles\/262464\/\" rel=\"noopener noreferrer nofollow\">https:\/\/lwn.net\/Articles\/262464\/<\/a><\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440  \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443 \u0442\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/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\/post\/712882\/\"> https:\/\/habr.com\/ru\/post\/712882\/<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>Lock-free \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0435, \u043d\u043e \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0432\u044b\u0441\u043e\u043a.  \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0435\u0439\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c  RCU (Read\u2013Copy-Update). \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c. <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Read-copy-update\" rel=\"noopener noreferrer nofollow\">Wikipedia<\/a>.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/liburcu.org\/\" rel=\"noopener noreferrer nofollow\">liburcu<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0448\u0442\u0430\u0442\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Ubuntu.  <\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/github.com\/vic-35\/test_liburcu\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/vic-35\/test_liburcu<\/a> , \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0432 QT creator \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430. <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f RCU \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0443\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 RCU \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u0438\u0442\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f rcu_register_thread() \u0438 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 rcu_unregister_thread(). <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 , \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c SpinLock \u0438 RCU. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0438\u0442\u0435\u0439 , \u043e\u0434\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f , \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e  \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435  \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0420\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0436\u0434\u0435\u0442 10 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043c\u044c\u044e\u0442\u0435\u043a\u0441 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0438\u0442\u0435\u0439. \u0412 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435 \u0432\u0438\u0434\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u043d\u0438\u0442\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>SpinLock \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435-\u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0432 SpinLock, \u0432 \u043e\u0434\u043d\u0443 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a  \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439  result.<\/p>\n<pre><code class=\"cpp\">    while (pthread_mutex_trylock(&amp;m1) == EBUSY) {         pthread_spin_lock(&amp;s1);         usleep(1);         if (i == 0) {             unsigned int rez = *result;             *result = 0x0;             free(result);             result = malloc(sizeof(unsigned int));             if (rez == REZ1) {                 *result = REZ2;                 count++;             } else {                 *result = REZ1;                 count1++;             }         } else {             unsigned int rez = *result;             if (rez != REZ1 &amp;&amp; rez != REZ2) {                 printf(\"Fatal error :%lld :%lld :%lld\\n\", i, count, count1);                 exit(-1);             }             if (rez == REZ1) {                 count++;             } else {                 count1++;             }         }         pthread_spin_unlock(&amp;s1);     } <\/code><\/pre>\n<p>RCU \u0432\u0435\u0440\u0441\u0438\u044f \u0442\u0430\u043a\u0436\u0435  \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430. \u041f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c  \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432  rcu_read_lock(), \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e rcu_read_unlock(). \u041c\u0435\u0436\u0434\u0443 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043d\u0438\u0442\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e *result , \u043d\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u043c rcu_xchg_pointer(&amp;result, new_result), \u0430 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0443 \u0432\u0441\u0435\u0445 \u043d\u0438\u0442\u0435\u0439, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 rcu_read_lock \u0441\u0435\u043a\u0446\u0438\u0438 , \u0444\u0443\u043d\u043a\u0446\u0438\u044f synchronize_rcu(). <\/p>\n<pre><code class=\"cpp\">    while (pthread_mutex_trylock(&amp;m1) == EBUSY) {         rcu_read_lock();         usleep(1);         if (i == 0) {             unsigned int rez = *result;             unsigned int *new_result = malloc(sizeof(unsigned int));             if (rez == REZ1) {                 *new_result = REZ2;                 count++;             } else {                 *new_result = REZ1;                 count1++;             }             rcu_read_unlock();              unsigned int *old_result = rcu_xchg_pointer(&amp;result, new_result);             synchronize_rcu();              if (old_result)                 *old_result = 0;             free(old_result);          } else {             unsigned int rez = *result;             if (rez != REZ1 &amp;&amp; rez != REZ2) {                 printf(\"Fatal error :%lld :%lld :%lld\\n\", i, count, count1);                 exit(-1);             }             if (rez == REZ1) {                 count++;              } else {                 count1++;             }             rcu_read_unlock();         }     } <\/code><\/pre>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f SpinLock \u0437\u0430\u0442\u0435\u043c RCU.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043e\u0434\u043d\u043e\u0439 \u043d\u0438\u0442\u0438 , \u0435\u0441\u0442\u044c \u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 SpinLock \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0446\u0438\u043a\u043b\u043e\u0432 \u0447\u0442\u0435\u043d\u0438\u044f &#8212; \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<blockquote>\n<p>start :0<br \/>end :0 :86325 :86324<br \/>start :0<br \/>end :0 :84708 :84708<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043d\u0438\u0442\u0435\u0439. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 SpinLock \u0440\u0435\u0437\u043a\u043e \u0441\u0434\u0430\u0435\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438\u0442\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0436\u0434\u0443\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0443.<\/p>\n<blockquote>\n<p> start :0<br \/> start :1<br \/> start :5<br \/> start :4<br \/> start :2<br \/> start :3<br \/> end :2 :17574 :24472<br \/> end :4 :1773 :2824<br \/> end :0 :3639 :3638<br \/> end :1 :16770 :16452<br \/> end :5 :21121 :32123<br \/> end :3 :18075 :22640<br \/> start :0<br \/> start :3<br \/> start :2<br \/> start :5<br \/> start :4<br \/> start :1<br \/> end :5 :85755 :85766<br \/> end :3 :86214 :86157<br \/> end :2 :86143 :86066<br \/> end :4 :85594 :85790<br \/> end :0 :41820 :41820<br \/> end :1 :85583 :85670<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435. \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u044b pthread_spin_lock(&amp;s1) \u0438 pthread_spin_unlock(&amp;s1). \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438, \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.  <\/p>\n<blockquote>\n<p>start :0<br \/> start :1<br \/> start :2<br \/> start :4<br \/> start :5<br \/> start :3<br \/> Fatal error :4 :18 :18<\/p>\n<\/blockquote>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f  \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 Lock-free \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440. \u0422\u0435\u0441\u0442 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439,  \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438  \u043d\u0438\u0442\u0438 \u043d\u0435 \u0441\u0442\u043e\u044f\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443 \u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e.  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e synchronize_rcu \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 rcu_read_lock \u0441\u0435\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 rcu_read_lock \u0441\u0435\u043a\u0446\u0438\u0438  \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432,  \u043e\u043d \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u0435\u043d \u0438 \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430. <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 liburcu. <\/p>\n<p><a href=\"https:\/\/liburcu.org\/\" rel=\"noopener noreferrer nofollow\">https:\/\/liburcu.org\/<\/a> <\/p>\n<p><a href=\"https:\/\/lwn.net\/Articles\/262464\/\" rel=\"noopener noreferrer nofollow\">https:\/\/lwn.net\/Articles\/262464\/<\/a><\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440  \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443 \u0442\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/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\/post\/712882\/\"> https:\/\/habr.com\/ru\/post\/712882\/<\/a><br \/><\/br><\/br><\/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-344487","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344487","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=344487"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344487\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}