{"id":308640,"date":"2020-08-18T09:01:58","date_gmt":"2020-08-18T09:01:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=308640"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=308640","title":{"rendered":"STL, allocator, \u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0435\u0451 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/515242\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/h1\/l-\/v_\/h1l-v_ou7wyccqrwkr1qvbvqpfs.png\"><\/div>\n<p>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D0%B7%D0%B4%D0%B5%D0%BB%D1%8F%D0%B5%D0%BC%D0%B0%D1%8F_%D0%BF%D0%B0%D0%BC%D1%8F%D1%82%D1%8C\" rel=\"nofollow\">\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/a> \u2014 \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u041d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 (\u0442\u0440\u0443\u0431\u044b, \u0441\u043e\u043a\u0435\u0442\u044b \u0432\u0441\u0435\u0445 \u043c\u0430\u0441\u0442\u0435\u0439, \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 &#8230;), \u0437\u0434\u0435\u0441\u044c \u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043f\u043e\u043b\u043d\u0430\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0438\u0448\u0443\u0442 \u043a\u0442\u043e \u0432\u043e \u0447\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434. <\/p>\n<p>  \u0422\u0430\u043a \u0438 \u0430\u0432\u0442\u043e\u0440 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0437\u0430\u0434\u0430\u043b\u0441\u044f \u043c\u044b\u0441\u043b\u044c\u044e, \u0430 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u2026 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445. \u0412\u043e\u043e\u0431\u0449\u0435-\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0434\u0435\u043b\u0430\u0435\u0442 fork, \u0430 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432? \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0435\u0441\u0442\u044c fork. <\/p>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0441\u043e\u0432\u043f\u0430\u043b\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u0447\u0442\u043e \u0441 \u0442\u043e\u0433\u043e? \u041a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u044d\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442 \u043a\u0443\u0447\u0438 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u0438. \u0421\u0442\u0430\u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438 \u0421++, \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439, \u043a\u0441\u0442\u0430\u0442\u0438, \u043f\u0440\u0438\u043c\u0435\u0440. \u041d\u0435 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u0432\u0442\u043e\u0440 \u0441\u0438\u043b\u044c\u043d\u043e \u043b\u044e\u0431\u0438\u043b STL, \u043d\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u0438 \u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438. \u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 (\u043a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0441\u044f) \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0412\u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u043e\u043d\u0430 \u0438 \u0447\u0435\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c, \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u0435\u0435.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 <\/h3>\n<p>  \u0418\u0434\u0435\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u0430 \u0438 \u0438\u0437\u044f\u0449\u043d\u0430 \u2014 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0441\u0432\u043e\u0451\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0435\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u0449\u0435\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0435, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0432\u0443\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u043c \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043e\u0434\u043d\u0443 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  \u0410 \u0441 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c 64-\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0438 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%BE%D0%B3%D0%B5%D1%80%D0%B5%D0%BD%D1%82%D0%BD%D0%BE%D1%81%D1%82%D1%8C_%D0%BA%D1%8D%D1%88%D0%B0\" rel=\"nofollow\">\u043a\u043e\u0433\u0435\u0440\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u043a\u044d\u0448\u0430<\/a>, \u0438\u0434\u0435\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u0434\u044b\u0445\u0430\u043d\u0438\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u0443\u0444\u0435\u0440 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u201c\u0442\u0440\u0443\u0431\u044b\u201d \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438, \u0430 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u201c\u0442\u0440\u0430\u043d\u0441\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0435\u0440 \u043a\u043e\u043d\u0442\u0438\u043d\u0443\u0443\u043c\u0430\u201d \u2014 \u043a\u0440\u0430\u0439\u043d\u0435 \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0438 \u043c\u043e\u0449\u043d\u044b\u0439 \u043f\u0440\u0438\u0431\u043e\u0440, \u043f\u0440\u0438\u0447\u0435\u043c, \u043b\u0438\u0448\u044c \u0435\u0433\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0430 \u0435\u0433\u043e \u043c\u043e\u0449\u0438. <\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.  <\/p>\n<ul>\n<li>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u201cshared memory\u201d \u043f\u0440\u0438 \u043e\u0431\u043c\u0435\u043d\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 MS SQL. <a href=\"https:\/\/efsol.ru\/articles\/1s-mssql-postgresql.html\" rel=\"nofollow\">\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442<\/a> \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (~10&#8230;15%)<\/li>\n<li>Mysql \u0442\u0430\u043a\u0436\u0435 <a href=\"https:\/\/mysqlserverteam.com\/improving-the-performance-of-mysql-on-windows\/#:~:text=Shared%20memory%20connections%20are%20obviously,use%20the%20shared_memory%20system%20variable.\" rel=\"nofollow\">\u0438\u043c\u0435\u0435\u0442<\/a> \u043f\u043e\u0434 Windows \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u201cshared memory\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432.<\/li>\n<li>Sqlite <a href=\"https:\/\/sqlite.com\/wal.html\" rel=\"nofollow\">\u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442<\/a> \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043f\u043e WAL-\u0444\u0430\u0439\u043b\u0443. \u041f\u0440\u0438\u0447\u0435\u043c \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c\u0438 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/Chroot\" rel=\"nofollow\">chroot<\/a>).<\/li>\n<li>PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 fork \u0434\u043b\u044f \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u0438\u0447\u0435\u043c \u044d\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0438\u0436\u0435.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ed\/jq\/dt\/edjqdttqmxwkcwia9qvfcwdt9f0.png\"><br \/>  \u0424\u0438\u0433.1 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 PostgreSQL (<a href=\"https:\/\/pdfslide.net\/technology\/inside-postgres-shared-memory-with-enterprisedb.html\" rel=\"nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>)<\/li>\n<\/ul>\n<p>  \u0418\u0437 \u043e\u0431\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0430 \u043a\u0430\u043a\u043e\u0439 \u0431\u044b \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c? \u041d\u0430 \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u2014 \u0436\u0435\u043b\u0430\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0414\u0430, \u043d\u0443\u0436\u043d\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f (\u0430 \u043e\u043d\u0430 \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u0430), \u043d\u043e \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0451\u0448\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0448\u044c! \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u2026 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0438\u0442\u044c.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <u>\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e-\u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430<\/u>:  <\/p>\n<ul>\n<li>\u0435\u0441\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433 <i>std::map&lt;std::string, std::string&gt;<\/i>, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/li>\n<li>\u0438\u043c\u0435\u0435\u043c N \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432\u043d\u043e\u0441\u044f\u0442\/\u043c\u0435\u043d\u044f\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043d\u043e\u043c\u0435\u0440\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (ex: key_1_\u2026 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u043e\u043c\u0435\u0440 1)<\/li>\n<li>\u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/li>\n<\/ul>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u2014 \u0440\u0430\u0437 \u0443 \u043d\u0430\u0441 <i>\u0435\u0441\u0442\u044c std::string<\/i> \u0438 <i>std::map<\/i>, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 STL.<\/p>\n<h3>\u0410\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 STL<\/h3>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>xalloc\/xfree<\/i> \u043a\u0430\u043a \u0430\u043d\u0430\u043b\u043e\u0433\u0438 <i>malloc\/free<\/i>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">template &lt;typename T&gt; class stl_buddy_alloc { public: \ttypedef T                 value_type; \ttypedef value_type*       pointer; \ttypedef value_type&amp;       reference; \ttypedef const value_type* const_pointer; \ttypedef const value_type&amp; const_reference; \ttypedef ptrdiff_t         difference_type; \ttypedef size_t            size_type; public: \tstl_buddy_alloc() throw() \t{\t\/\/ construct default allocator (do nothing) \t} \tstl_buddy_alloc(const stl_buddy_alloc&lt;T&gt; &amp;) throw() \t{\t\/\/ construct by copying (do nothing) \t} \ttemplate&lt;class _Other&gt; \tstl_buddy_alloc(const stl_buddy_alloc&lt;_Other&gt; &amp;) throw() \t{\t\/\/ construct from a related allocator (do nothing) \t}  \tvoid deallocate(pointer _Ptr, size_type) \t{\t\/\/ deallocate object at _Ptr, ignore size \t\txfree(_Ptr); \t} \tpointer allocate(size_type _Count) \t{\t\/\/ allocate array of _Count elements \t\treturn (pointer)xalloc(sizeof(T) * _Count); \t} \tpointer allocate(size_type _Count, const void *) \t{\t\/\/ allocate array of _Count elements, ignore hint \t\treturn (allocate(_Count)); \t} };<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0441\u0430\u0434\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0433\u043e <i>std::map &amp; std::string<\/i><\/p>\n<pre><code class=\"cpp\"> template &lt;typename _Kty, typename _Ty&gt; class q_map :      public std::map&lt;         _Kty,          _Ty,          std::less&lt;_Kty&gt;,          stl_buddy_alloc&lt;std::pair&lt;const _Kty, _Ty&gt; &gt;      &gt; { };  typedef std::basic_string&lt;         char,          std::char_traits&lt;char&gt;,          stl_buddy_alloc&lt;char&gt; &gt; q_string<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 <i>xalloc\/xfree<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0432\u0435\u0440\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0430\u043c\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e.<\/p>\n<h3>\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/h3>\n<p>  \u0420\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u0435 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/cpp\/parallel\/thread-local-storage-tls?view=vs-2019\" rel=\"nofollow\">thread_local<\/a> \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0432 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u043c\u0435\u0441\u0442\u043e. \u0421 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0438\u043b\u0438\u044f.<\/p>\n<h4><i>Windows<\/i><\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u043f\u043e\u043a\u0440\u044b\u0442\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u043f\u043e\u0434\u043a\u0430\u0447\u043a\u0438, \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043c\u0438\u043c\u043e \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u0431\u0443\u0434\u0435\u043c \u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u0449\u0435\u0439 \u043f\u043e\u0434\u043a\u0430\u0447\u043a\u043e\u0439 \u0438\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b.<br \/> \n<pre><code class=\"cpp\">HANDLE hMapFile = CreateFileMapping( \tINVALID_HANDLE_VALUE,     \/\/ use paging file \tNULL,                     \/\/ default security \tPAGE_READWRITE,           \/\/ read\/write access \t(alloc_size &gt;&gt; 32)        \/\/ maximum object size (high-order DWORD) \t(alloc_size &amp; 0xffffffff),\/\/ maximum object size (low-order DWORD) \t&quot;Local\\\\SomeData&quot;);       \/\/ name of mapping object<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0444\u0438\u043a\u0441 \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430 \u201cLocal\\\\\u201d <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/termserv\/kernel-object-namespaces\" rel=\"nofollow\">\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442<\/a>, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d \u0441\u0435\u0441\u0441\u0438\u0438.<\/li>\n<li>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c<br \/> \n<pre><code class=\"cpp\">HANDLE hMapFile = OpenFileMapping( \tFILE_MAP_ALL_ACCESS,      \/\/ read\/write access \tFALSE,                    \/\/ do not inherit the name \t&quot;Local\\\\SomeData&quot;);       \/\/ name of mapping object<\/code><\/pre>\n<\/li>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0433\u043c\u0435\u043d\u0442, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435<br \/> \n<pre><code class=\"cpp\">void *hint = (void *)0x200000000000ll; unsigned char *shared_ptr = (unsigned char*)MapViewOfFileEx( \thMapFile,                 \/\/ handle to map object \tFILE_MAP_ALL_ACCESS,      \/\/ read\/write permission \t0,                        \/\/ offset in map object (high-order DWORD) \t0,                        \/\/ offset in map object (low-order DWORD) \t0,                        \/\/ segment size, \thint);                    \/\/ \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430 <\/code><\/pre>\n<p>segment size 0 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0440\u0430\u0437\u043c\u0435\u0440, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0441\u0434\u0432\u0438\u0433\u0430.<\/p>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u2014 hint. \u0415\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0437\u0430\u0434\u0430\u043d (NULL), \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u0434\u0431\u0435\u0440\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u0441\u0432\u043e\u0451 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435. \u041d\u043e \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0435, \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044f \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u043c\u044b \u0438 \u0434\u043e\u0431\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 32-\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u0430\u0439\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0437\u0430\u043d\u044f\u0442\u044b\u0439 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e, \u0432 64-\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u043c \u0436\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u0442, \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435.<\/li>\n<\/ul>\n<p>  <\/p>\n<h4><i>Linux<\/i><\/h4>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u0441\u0451 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435.  <\/p>\n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438\n<pre><code class=\"cpp\">  int fd = shm_open(                  \u201c\/SomeData\u201d,               \/\/ \u0438\u043c\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \/                  O_CREAT | O_EXCL | O_RDWR, \/\/ flags, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e open                  S_IRUSR | S_IWUSR);        \/\/ mode, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e open    ftruncate(fd, alloc_size); <\/code><\/pre>\n<p>ftruncate \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 shm_open \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0444\u0430\u0439\u043b\u0430 \u0432 \/dev\/shm\/. \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0447\u0435\u0440\u0435\u0437 shmget\\shmat \u043e\u0442 SysV, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f ftok (inode \u043e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430).<\/li>\n<li>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438\n<pre><code class=\"cpp\">int fd = shm_open(\u201c\/SomeData\u201d, O_RDWR, 0);<\/code><\/pre>\n<\/li>\n<li>\u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\n<pre><code class=\"cpp\">  void *hint = (void *)0x200000000000ll;   unsigned char *shared_ptr = (unsigned char*) = mmap(                    hint,                      \/\/ \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430                    alloc_size,                \/\/ segment size,                    PROT_READ | PROT_WRITE,    \/\/ protection flags                    MAP_SHARED,                \/\/ sharing flags                    fd,                        \/\/ handle to map object                    0);                        \/\/ offset <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u0432\u0430\u0436\u0435\u043d hint.<\/li>\n<\/ul>\n<h4><i>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443<\/i><\/h4>\n<p>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 (hint), \u043a\u0430\u043a\u043e\u0432\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435? <br \/>  \u0412\u043e\u043e\u0431\u0449\u0435-\u0442\u043e, \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. <br \/>  <b>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445<\/b>, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435\/\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0435. \u0417\u0434\u0435\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u041f\u0440\u0438 \u043f\u0440\u043e\u043c\u0430\u0445\u0435 \u0432 \u043a\u044d\u0448\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Translation_lookaside_buffer\" rel=\"nofollow\">TLB<\/a>, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u201c\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u201d (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Page_table\" rel=\"nofollow\">page table<\/a>). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 IA-32 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/d7\/gm\/y1\/d7gmy1t43aryybkcljmfozvuwqq.png\"><br \/>  \u0424\u0438\u0433.2 \u0441\u043b\u0443\u0447\u0430\u0439 4K \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0432\u0437\u044f\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Page_table\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>  \u0412\u0445\u043e\u0434\u043e\u043c \u0432 \u0434\u0435\u0440\u0435\u0432\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 CR3, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u2014 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 32 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 32 \u0440\u0430\u0437\u0440\u044f\u0434\u0430, \u0432\u0441\u0451 \u0447\u0435\u0441\u0442\u043d\u043e.<\/p>\n<p>  \u0412 AMD64 \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ji\/wc\/uc\/jiwcuceyyh-f-miecczhhh_9g1o.png\"><br \/>  \u0424\u0438\u0433.3 AMD64, 4K \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0432\u0437\u044f\u0442\u043e <a href=\"http:\/\/developer.amd.com\/wordpress\/media\/2012\/10\/24593_APM_v2.pdf\" rel=\"nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a><\/p>\n<p>  \u0412 CR3 \u0442\u0435\u043f\u0435\u0440\u044c 40 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e 20 \u0440\u0430\u043d\u0435\u0435, \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 4 \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d 52 \u0440\u0430\u0437\u0440\u044f\u0434\u0430\u043c\u0438 \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d 48 \u0440\u0430\u0437\u0440\u044f\u0434\u0430\u043c\u0438.<\/p>\n<p>  \u0418 \u043b\u0438\u0448\u044c \u0432(\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441) \u043c\u0438\u043a\u0440\u043e\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ice_Lake_(microprocessor)\" rel=\"nofollow\">Ice Lake<\/a>(Intel) <a href=\"https:\/\/en.wikipedia.org\/wiki\/Intel_5-level_paging\" rel=\"nofollow\">\u0434\u043e\u0437\u0432\u043e\u043b\u0435\u043d\u043e<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 57 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 (\u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 52 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e) \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 5-\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. <\/p>\n<p>  \u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043b\u0438\u0448\u044c \u043e\u0431 Intel\/AMD. \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f, \u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/AArch64\" rel=\"nofollow\">Aarch64<\/a> \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c 3 \u0438\u043b\u0438 4 \u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 39 \u0438\u043b\u0438 48 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432 \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0430\u0434\u0440\u0435\u0441\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e (<a href=\"https:\/\/www.kernel.org\/doc\/html\/latest\/arm64\/memory.html\" rel=\"nofollow\">1<\/a>).<\/p>\n<p>  <b>\u0412\u043e \u0432\u0442\u043e\u0440\u044b\u0445<\/b>, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. Microsoft, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/windows\/win32\/memory\/memory-limits-for-windows-releases?redirectedfrom=MSDN#memory_limits\" rel=\"nofollow\">\u043d\u0430\u043b\u0430\u0433\u0430\u0435\u0442<\/a> (44 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u0434\u043e 8.1\/Server12, 48 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441) \u0442\u0430\u043a\u043e\u0432\u044b\u0435 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u041e\u0421 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0445 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0447\u0438\u043c, 48 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432, \u044d\u0442\u043e 65 \u0442\u044b\u0441\u044f\u0447 \u0440\u0430\u0437 \u043f\u043e 4\u0413\u0431, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0430 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f \u0443\u0433\u043e\u043b\u043e\u043a, \u043a\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0442\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0438\u043c hint-\u043e\u043c.<\/p>\n<h3>\u0410\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/h3>\n<p>  \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445. \u0410\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0436\u0438\u0442\u044c \u043d\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044f \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043c \u0436\u0435. <\/p>\n<p>  \u0412\u043e \u0432\u0442\u043e\u0440\u044b\u0445. \u041c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435 \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u043e\u0433\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043b\u044e\u0431\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Thread-local_storage\" rel=\"nofollow\">TLS<\/a> \u043d\u0435\u0443\u043c\u0435\u0441\u0442\u043d\u044b.<\/p>\n<p>  \u0412 \u0442\u0440\u0435\u0442\u044c\u0438\u0445. \u0420\u0430\u0437 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0441\u0430\u043c \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0436\u0438\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e, \u043e\u0441\u043e\u0431\u0443\u044e \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fragmentation_(computer)#External_fragmentation\" rel=\"nofollow\">\u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  \u0412 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0445. \u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u041e\u0421 \u0437\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b. \u0422\u0430\u043a, <a href=\"http:\/\/gee.cs.oswego.edu\/dl\/html\/malloc.html\" rel=\"nofollow\">dlmalloc<\/a>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Mmap\" rel=\"nofollow\">mmap<\/a>. \u0414\u0430, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0443\u0447\u0438\u0442\u044c, \u0437\u0430\u0432\u044b\u0441\u0438\u0432 \u043f\u043e\u0440\u043e\u0433, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435.<\/p>\n<p>  \u0412 \u043f\u044f\u0442\u044b\u0445. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0433\u043e\u0434\u044f\u0442\u0441\u044f, \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0430\u043c\u0438, \u043b\u0438\u0431\u043e \u0447\u0442\u043e-\u0442\u043e, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043f\u0438\u043d\u043b\u043e\u043a\u0438. \u0421\u043a\u0430\u0436\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u043a\u043e\u0433\u0435\u0440\u0435\u043d\u0442\u043d\u043e\u043c\u0443 \u043a\u044d\u0448\u0443. \u0412 posix \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 <a href=\"http:\/\/www.kernel.org\/doc\/man-pages\/online\/pages\/man3\/sem_init.3.html\" rel=\"nofollow\">\u0431\u0435\u0437\u044b\u043c\u044f\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0435\u043c\u0430\u0444\u043e\u0440\u044b<\/a>.<\/p>\n<p>  \u0418\u0442\u043e\u0433\u043e, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0432\u0441\u0451 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0436\u0438\u0432\u043e\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Buddy_memory_allocation\" rel=\"nofollow\">\u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0431\u043b\u0438\u0437\u043d\u0435\u0446\u043e\u0432<\/a> (\u043b\u044e\u0431\u0435\u0437\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u043e\u043c \u0410\u0440\u0442\u044e\u0448\u0438\u043d\u044b\u043c, \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439), \u0432\u044b\u0431\u043e\u0440 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u043c.<\/p>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0434\u043e \u043b\u0443\u0447\u0448\u0438\u0445 \u0432\u0440\u0435\u043c\u0451\u043d, \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"cpp\">class BuddyAllocator { public: \tBuddyAllocator(uint64_t maxCapacity, u_char * buf, uint64_t bufsize); \t~BuddyAllocator(){};  \tvoid *allocBlock(uint64_t nbytes); \tvoid freeBlock(void *ptr); ... };<\/code><\/pre>\n<p>\u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0442.\u043a. \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 BuddyAllocator \u043d\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442.<\/p>\n<h3>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>  \u0420\u0430\u0437 \u0432\u0441\u0451 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0443 \u044d\u0442\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u044d\u0442\u043e\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">struct glob_header_t { \t\/\/ \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u043d\u0430\u0435\u0442 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 magic \tuint64_t magic_; \t\/\/ hint \u0434\u043b\u044f \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \tconst void *own_addr_; \t\/\/ \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \tBuddyAllocator alloc_; \t\/\/ \u0441\u043f\u0438\u043d\u043b\u043e\u043a \tstd::atomic_flag lock_; \t\/\/ \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \tq_map&lt;q_string, q_string&gt; q_map_;  \tstatic const size_t alloc_shift = 0x01000000; \tstatic const size_t balloc_size = 0x10000000; \tstatic const size_t alloc_size = balloc_size + alloc_shift; \tstatic glob_header_t *pglob_; }; static_assert (     sizeof(glob_header_t) &lt; glob_header_t::alloc_shift,      &quot;glob_header_t size mismatch&quot;);  glob_header_t *glob_header_t::pglob_ = NULL;<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><i>own_addr_<\/i> \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435, \u043a\u0442\u043e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u043a \u043d\u0435\u0439 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u0443\u0437\u043d\u0430\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 (hint) \u0438 \u043f\u0435\u0440\u0435-\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438<\/li>\n<li>\u0432\u043e\u0442 \u0442\u0430\u043a \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043d\u0435\u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e<\/li>\n<li>\u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440(\u044b) \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a:\n<pre><code class=\"cpp\">glob_header_t::pglob_ = (glob_header_t *)shared_ptr;  new (&amp;glob_header_t::pglob_-&gt;alloc_)         qz::BuddyAllocator(                 \/\/ \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440                 glob_header_t::balloc_size,                 \/\/ \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c                 shared_ptr + glob_header_t::alloc_shift,                 \/\/ \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438                 glob_header_t::alloc_size - glob_header_t::alloc_shift;  new (&amp;glob_header_t::pglob_-&gt;q_map_)                  q_map&lt;q_string, q_string&gt;();  glob_header_t::pglob_-&gt;lock_.clear(); <\/code><\/pre>\n<\/li>\n<li>\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0451 \u0432 \u0433\u043e\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435<\/li>\n<li>\u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043a\u0440\u043e\u043c\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <i>xalloc\/xfree<\/i>\n<pre><code class=\"cpp\">void *xalloc(size_t size) { \treturn glob_header_t::pglob_-&gt;alloc_.allocBlock(size); } void xfree(void* ptr) { \tglob_header_t::pglob_-&gt;alloc_.freeBlock(ptr); } <\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c.<\/p>\n<h3>\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442<\/h3>\n<p>  \u0421\u0430\u043c \u0442\u0435\u0441\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442:<\/p>\n<pre><code class=\"cpp\">for (int i = 0; i &lt; 100000000; i++) {         char buf1[64];         sprintf(buf1, &quot;key_%d_%d&quot;, curid, (i % 100) + 1);         char buf2[64];         sprintf(buf2, &quot;val_%d&quot;, i + 1);          LOCK();          qmap.erase(buf1); \/\/ \u043f\u0443\u0441\u0442\u044c \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u0442\u0440\u0443\u0434\u0438\u0442\u0441\u044f         qmap[buf1] = buf2;          UNLOCK(); } <\/code><\/pre>\n<p>  <b>Curid<\/b> \u2014 \u044d\u0442\u043e \u043d\u043e\u043c\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\/\u043f\u043e\u0442\u043e\u043a\u0430, \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0441\u043e\u0437\u0434\u0430\u0432\u0448\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 curid, \u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u044d\u0442\u043e \u043d\u0435\u0432\u0430\u0436\u043d\u043e.<br \/>  <b>Qmap<\/b>,<b> LOCK\/UNLOCK<\/b> \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0435.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442\u043e\u0432  <\/p>\n<ol>\n<li><b>THR_MTX<\/b> \u2014 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, <br \/>  \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 <i>std::recursive_mutex<\/i>, <br \/>  <b>qmap<\/b> \u2014 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f <i>std::map&lt;std::string, std::string&gt;<\/i><\/li>\n<li><b>THR_SPN<\/b> \u2014 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, <br \/>  \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0438\u043d\u043b\u043e\u043a:\n<pre><code class=\"cpp\">std::atomic_flag slock; .. while (slock.test_and_set(std::memory_order_acquire));  \/\/ acquire lock \u2026 slock.clear(std::memory_order_release);                 \/\/ release lock<\/code><\/pre>\n<p><b>qmap<\/b> \u2014 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f <i>std::map&lt;std::string, std::string&gt;<\/i><\/li>\n<li><b>PRC_SPN<\/b> \u2014 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, <br \/>  \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0438\u043d\u043b\u043e\u043a:\n<pre><code class=\"cpp\">while (glob_header_t::pglob_-&gt;lock_.test_and_set(              \/\/ acquire lock         std::memory_order_acquire));                           \u2026 glob_header_t::pglob_-&gt;lock_.clear(std::memory_order_release); \/\/ release lock<\/code><\/pre>\n<p><b>qmap<\/b> \u2014 <i>glob_header_t::pglob_-&gt;q_map_<\/i><\/li>\n<li><b>PRC_MTX<\/b> \u2014 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, <br \/>  \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/sync\/using-named-objects\" rel=\"nofollow\">\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0443\u0442\u0435\u043a\u0441<\/a>. <br \/>  <b>qmap<\/b> \u2014 <i>glob_header_t::pglob_-&gt;q_map_<\/i><\/li>\n<\/ol>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b (\u0442\u0438\u043f \u0442\u0435\u0441\u0442\u0430 vs. \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432\\\u043f\u043e\u0442\u043e\u043a\u043e\u0432):  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th><\/th>\n<th>1<\/th>\n<th>2<\/th>\n<th>4<\/th>\n<th>8<\/th>\n<th>16<\/th>\n<\/tr>\n<tr>\n<td><b>THR_MTX<\/b><\/td>\n<td>1\u201956\u2019\u2019<\/td>\n<td>5\u201941\u2019\u2019<\/td>\n<td>7\u201953\u2019\u2019<\/td>\n<td>51\u201938\u2019\u2019<\/td>\n<td>185\u201949<\/td>\n<\/tr>\n<tr>\n<td><b>THR_SPN<\/b><\/td>\n<td>1\u201926\u2019\u2019<\/td>\n<td>7\u201938\u2019\u2019<\/td>\n<td>25\u201930\u2019\u2019<\/td>\n<td>103\u201929\u2019\u2019<\/td>\n<td>347\u201904\u2019\u2019<\/td>\n<\/tr>\n<tr>\n<td><b>PRC_SPN<\/b><\/td>\n<td>1\u201924\u2019\u2019<\/td>\n<td>7\u201927\u2019\u2019<\/td>\n<td>24\u201902\u2019\u2019<\/td>\n<td>92\u201934\u2019\u2019<\/td>\n<td>322\u201941\u2019\u2019<\/td>\n<\/tr>\n<tr>\n<td><b>PRC_MTX<\/b><\/td>\n<td>4\u201955\u2019\u2019<\/td>\n<td>13\u201901\u2019\u2019<\/td>\n<td>78\u201914\u2019\u2019<\/td>\n<td>133\u201925\u2019\u2019<\/td>\n<td>357\u201921\u2019\u2019<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u043d\u0430 \u0434\u0432\u0443\u0445\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u043c (48 \u044f\u0434\u0435\u0440) \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0441 <br \/>  Xeon&reg; Gold 5118 2.3GHz, Windows Server 2016.<\/p>\n<h3>\u0418\u0442\u043e\u0433\u043e<\/h3>\n<p>  <\/p>\n<ul>\n<li>\u0414\u0430, <b>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/b> \u043e\u0431\u044a\u0435\u043a\u0442\u044b\/\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b <b>STL<\/b> (\u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438) \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 <b>\u043c\u043e\u0436\u043d\u043e<\/b> \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. <\/li>\n<li>\u041f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044f\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0448\u0430 \u043d\u0435\u0442, \u0441\u043a\u043e\u0440\u0435\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, PRC_SPN \u0434\u0430\u0436\u0435 \u0447\u0443\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 THR_SPN. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0435, \u0437\u043d\u0430\u0447\u0438\u0442 <i>BuddyAllocator<\/i> \u0447\u0443\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 <i>malloc\\free<\/i> \u043e\u0442 MS (\u043f\u0440\u0438 \u043d\u0435\u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438).<\/li>\n<li>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u044f. \u0414\u0430\u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c + std::mutex \u0432 \u044d\u0442\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0417\u0434\u0435\u0441\u044c \u0431\u044b\u043b\u0438 \u0431\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u044b lock-free \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430.<\/li>\n<\/ul>\n<h3>\u0412\u0434\u043e\u0433\u043e\u043d\u043a\u0443<\/h3>\n<p>  \u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0439 \u201c\u0442\u0440\u0443\u0431\u044b\u201d, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0439 \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438. \u042d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0440\u043e\u0433\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u0422\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u043d\u0435 \u0434\u0435\u0448\u0435\u0432\u0430\u044f, \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u0435 PRC_MTX, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438, \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0443\u0445\u0443\u0434\u0448\u0438\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0440\u0430\u0437\u044b.<\/p>\n<p>  \u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0434\u043e\u0440\u043e\u0433\u043e\u0432\u0438\u0437\u043d\u044b \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0435\u0441\u043b\u0438 <i>std::(recursive_)mutex<\/i> (\u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0435\u043a\u0446\u0438\u044f \u043f\u043e\u0434 windows) <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/windows\/win32\/api\/synchapi\/nf-synchapi-initializecriticalsectionandspincount\" rel=\"nofollow\">\u0443\u043c\u0435\u0435\u0442<\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u043f\u0438\u043d\u043b\u043e\u043a, \u0442\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0443\u0442\u0435\u043a\u0441 \u2014 \u044d\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432, \u0432\u0445\u043e\u0434 \u0432 \u0440\u0435\u0436\u0438\u043c \u044f\u0434\u0440\u0430 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0430\u043c\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u0442\u0435\u0440\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u043c\/\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u0440\u043e\u0433\u043e.<\/p>\n<p>  \u041d\u043e \u0440\u0430\u0437 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u0430, \u043a\u0430\u043a \u0436\u0435 \u043d\u0430\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438? \u041e\u0442\u0432\u0435\u0442 \u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d \u2014 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f. \u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u0431\u0443\u0444\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0431\u0443\u0444\u0435\u0440 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043f\u0430\u043a\u0435\u0442\u0430, \u0442\u043e \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0440\u0435\u0436\u0435.<\/p>\n<p>  \u0423\u0434\u043e\u0431\u043d\u043e \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u2014 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u0445 (ex: \u043f\u0435\u0442\u043b\u044f \u0447\u0435\u0440\u0435\u0437 localhost) \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 (\u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438). \u0422.\u043a. \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0410 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443, \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.  <\/p>\n<ul>\n<li>\u043d\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438, \u043d\u0435 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438<\/li>\n<li>\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0442\u043e\u043a \u0447\u0435\u0441\u0442\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/li>\n<li>\u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e (\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f) \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0438\u043c, \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 delete, \u0432\u0441\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u043e\u0442 \u0432\u043e\u0437\u043d\u0438 \u0441 \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u044b\u043c \u0431\u0443\u0444\u0435\u0440\u043e\u043c<\/li>\n<li>\u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0430 (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u2014 \u0431\u0430\u0439\u0442 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u201cyou have mail\u201d) \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e \u0444\u0430\u043a\u0442\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0447\u0435\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <\/li>\n<\/ul>\n<h3>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a<\/h3>\n<p>  \u0427\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.  <\/p>\n<ol>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Run-time_type_information\" rel=\"nofollow\">RTTI<\/a>. \u041f\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c. <i>Std::type_info<\/i> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043d\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445.<\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u041f\u043e \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435. \u0422\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0441\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e\u0431 STL, \u0432\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0445 \u043f\u0430\u043c\u044f\u0442\u044c, \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043e\u0434\u043d\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u0441 \u043e\u0434\u043d\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0434\u0430 \u0438 \u0441\u0430\u043c\u0430 STL \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439. <\/li>\n<\/ol>\n<p>  <b>PS<\/b>: \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0443 \u0410\u0440\u0442\u044e\u0448\u0438\u043d\u0443 \u0438 \u0414\u043c\u0438\u0442\u0440\u0438\u044e \u0418\u043f\u0442\u044b\u0448\u0435\u0432\u0443(<a href=\"https:\/\/habr.com\/ru\/users\/dmitria\/\" class=\"user_link\">Dmitria<\/a>) \u0437\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/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=\"https:\/\/habr.com\/ru\/post\/515242\/\"> https:\/\/habr.com\/ru\/post\/515242\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/515242\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/h1\/l-\/v_\/h1l-v_ou7wyccqrwkr1qvbvqpfs.png\"><\/div>\n<p>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D0%B7%D0%B4%D0%B5%D0%BB%D1%8F%D0%B5%D0%BC%D0%B0%D1%8F_%D0%BF%D0%B0%D0%BC%D1%8F%D1%82%D1%8C\" rel=\"nofollow\">\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/a> \u2014 \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u041d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 (\u0442\u0440\u0443\u0431\u044b, \u0441\u043e\u043a\u0435\u0442\u044b \u0432\u0441\u0435\u0445 \u043c\u0430\u0441\u0442\u0435\u0439, \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 &#8230;), \u0437\u0434\u0435\u0441\u044c \u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043f\u043e\u043b\u043d\u0430\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0438\u0448\u0443\u0442 \u043a\u0442\u043e \u0432\u043e \u0447\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434. <\/p>\n<p>  \u0422\u0430\u043a \u0438 \u0430\u0432\u0442\u043e\u0440 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0437\u0430\u0434\u0430\u043b\u0441\u044f \u043c\u044b\u0441\u043b\u044c\u044e, \u0430 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u2026 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445. \u0412\u043e\u043e\u0431\u0449\u0435-\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0434\u0435\u043b\u0430\u0435\u0442 fork, \u0430 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432? \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0435\u0441\u0442\u044c fork. <\/p>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0441\u043e\u0432\u043f\u0430\u043b\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u0447\u0442\u043e \u0441 \u0442\u043e\u0433\u043e? \u041a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u044d\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442 \u043a\u0443\u0447\u0438 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u0438. \u0421\u0442\u0430\u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438 \u0421++, \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439, \u043a\u0441\u0442\u0430\u0442\u0438, \u043f\u0440\u0438\u043c\u0435\u0440. \u041d\u0435 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u0432\u0442\u043e\u0440 \u0441\u0438\u043b\u044c\u043d\u043e \u043b\u044e\u0431\u0438\u043b STL, \u043d\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u0438 \u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438. \u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 (\u043a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0441\u044f) \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0412\u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u043e\u043d\u0430 \u0438 \u0447\u0435\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c, \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u0435\u0435.  <\/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-308640","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/308640","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=308640"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/308640\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}