{"id":490204,"date":"2026-08-07T17:32:42","date_gmt":"2026-08-07T17:32:42","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=490204"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=490204","title":{"rendered":"64 \u0431\u0430\u0439\u0442\u0430 \u0438 \u043e\u0434\u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430: \u0440\u0430\u0437\u0431\u043e\u0440 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u044f\u0434\u0440\u0435 \u043d\u0430 Rust"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u044f \u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 \u0442\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u0422\u0430\u043a \u0438 \u0435\u0441\u0442\u044c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u043e \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0438 \u043c\u0435\u043d\u044c\u0448\u0435: \u043a\u0430\u043a \u0432 \u043c\u043e\u0451\u043c \u044f\u0434\u0440\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0442\u0430\u043c \u0437\u043d\u0430\u0435\u0442 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 Rust.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u044c. \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0443 \u043d\u0443\u0436\u0435\u043d \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c, \u0430 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0415\u0441\u043b\u0438 \u044d\u0442\u0438 \u0434\u0432\u043e\u0435 \u0440\u0430\u0437\u043e\u0439\u0434\u0443\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u0435\u043d\u0438\u044f\u0445, \u0432\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0412\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u044f\u0434\u0440\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0438\u0448\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043c\u0438\u043c\u043e \u0438 \u043f\u0430\u0434\u0430\u0435\u0442 \u0433\u0434\u0435-\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u043c\u0435\u0441\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<h3>\u0421\u0430\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c<\/h3>\n<p>asm<\/p>\n<pre><code>switch_context:    .byte 0xf3, 0x0f, 0x1e, 0xfa    mov qword ptr [rdi + {context_off} + 0],  r15    mov qword ptr [rdi + {context_off} + 8],  r14    mov qword ptr [rdi + {context_off} + 16], r13    mov qword ptr [rdi + {context_off} + 24], r12    mov qword ptr [rdi + {context_off} + 32], rbx    mov qword ptr [rdi + {context_off} + 40], rbp    lea rax, [rip + .Lswitch_return]    mov qword ptr [rdi + {context_off} + 48], rax    mov qword ptr [rdi + {context_off} + 56], rsp    mov r15, qword ptr [rsi + {context_off} + 0]    mov r14, qword ptr [rsi + {context_off} + 8]    mov r13, qword ptr [rsi + {context_off} + 16]    mov r12, qword ptr [rsi + {context_off} + 24]    mov rbx, qword ptr [rsi + {context_off} + 32]    mov rbp, qword ptr [rsi + {context_off} + 40]    mov rsp, qword ptr [rsi + {context_off} + 56]    jmp qword ptr [rsi + {context_off} + 48].Lswitch_return:    ret<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u0432\u0430\u0434\u0446\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0438 \u0432 \u043d\u0438\u0445 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u0441\u043c\u0435\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. <code>rdi<\/code> \u044d\u0442\u043e \u0443\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a, <code>rsi<\/code> \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0439, \u0442\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442 System V ABI.<\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u044d\u0442\u043e <code>endbr64<\/code>, \u043c\u0435\u0442\u043a\u0430 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439 \u0446\u0435\u043b\u0438 \u043d\u0435\u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0434\u043b\u044f Intel CET. \u0417\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0431\u0430\u0439\u0442\u0430\u043c\u0438.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0432\u0441\u0435\u0433\u043e \u0448\u0435\u0441\u0442\u044c<\/h3>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0434\u0430\u044e\u0442: \u0433\u0434\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b? \u0413\u0434\u0435 <code>rax<\/code>, <code>rcx<\/code>, <code>rdx<\/code>, \u0433\u0434\u0435 \u0432\u0441\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430?<\/p>\n<p>\u0418\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0438 \u044d\u0442\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u0430 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043e \u0432\u044b\u0437\u043e\u0432\u0430\u0445. \u041f\u043e System V \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0430 \u043b\u0430\u0433\u0435\u0440\u044f. Callee-saved (<code>rbx<\/code>, <code>rbp<\/code>, <code>r12<\/code>\u2013<code>r15<\/code>) \u043e\u0431\u044f\u0437\u0430\u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. Caller-saved \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435, \u0438 \u043e \u043d\u0438\u0445 \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430.<\/p>\n<p><code>switch_context<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 Rust \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0417\u043d\u0430\u0447\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0443\u0436\u0435 \u0441\u0430\u043c \u0440\u0430\u0441\u0441\u0442\u0430\u0432\u0438\u043b \u0432\u043e\u043a\u0440\u0443\u0433 \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u0431\u044b\u043b\u043e \u0434\u043e\u0440\u043e\u0433\u043e \u0438\u0437 caller-saved. \u0415\u0441\u043b\u0438 \u0431\u044b \u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b \u0438\u0445 \u0435\u0449\u0451 \u0440\u0430\u0437, \u044f \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440.<\/p>\n<p>\u041e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0448\u0435\u0441\u0442\u044c callee-saved \u043f\u043b\u044e\u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u0442\u0435\u043a\u0430 \u0438 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430. \u0412\u043e\u0441\u0435\u043c\u044c \u043f\u043e \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442, \u0440\u043e\u0432\u043d\u043e 64:<\/p>\n<p>rust<\/p>\n<pre><code>#[repr(C)]#[derive(Clone, Copy)]pub struct Context {    pub r15: u64,    pub r14: u64,    pub r13: u64,    pub r12: u64,    pub rbx: u64,    pub rbp: u64,    pub rip: u64,    pub rsp: u64,}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0443\u043a\u0430\u043c\u0438<\/h3>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435:<\/p>\n<p>asm<\/p>\n<pre><code>    lea rax, [rip + .Lswitch_return]    mov qword ptr [rdi + {context_off} + 48], rax<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0435\u0440\u0451\u0442 \u0430\u0434\u0440\u0435\u0441 \u043c\u0435\u0442\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0438 \u043a\u043b\u0430\u0434\u0451\u0442 \u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u0435 <code>rip<\/code> \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. \u0410 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 <code>ret<\/code>, \u0430 \u043f\u0440\u044b\u0436\u043a\u043e\u043c \u043f\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u043c\u0443 <code>rip<\/code> \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e:<\/p>\n<p>asm<\/p>\n<pre><code>    jmp qword ptr [rsi + {context_off} + 48]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <code>ret<\/code> \u0432\u0435\u0440\u043d\u0443\u043b \u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0443\u0434\u0430, \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u0448\u043b\u0438, \u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u043e\u0432\u043d\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0435: \u0443\u0439\u0442\u0438 \u0442\u0443\u0434\u0430, \u0433\u0434\u0435 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a. \u0421\u0442\u0435\u043a \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0432\u044b\u0448\u0435, \u0442\u0430\u043a \u0447\u0442\u043e <code>ret<\/code> \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u0431\u044b \u043f\u043e \u0447\u0443\u0436\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430, \u0438 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u044b \u043f\u043e\u0447\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u044b \u0432\u043e\u0432\u0441\u0435.<\/p>\n<p>\u041c\u0435\u0442\u043a\u0430 <code>.Lswitch_return<\/code> \u044d\u0442\u043e \u0442\u043e\u0447\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0442\u043e\u043a \u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u044f\u0442. \u0422\u0430\u043c \u0441\u0442\u043e\u0438\u0442 <code>ret<\/code>, \u0438 \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0442\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u044e\u0434\u0430 \u043f\u0440\u044b\u0433\u043d\u0435\u0442. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e: \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 <code>jmp<\/code> \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 <code>ret<\/code>, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0435\u0441\u0442\u044c <code>switch_first<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u0430: \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043d\u0435\u0447\u0435\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 <code>next<\/code>.<\/p>\n<h3>\u0422\u0430 \u0441\u0430\u043c\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430<\/h3>\n<p><code>{context_off}<\/code> \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u043e\u0442\u0441\u044e\u0434\u0430:<\/p>\n<p>rust<\/p>\n<pre><code>pub const CONTEXT_OFF: usize = core::mem::offset_of!(Thread, context);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 <code>global_asm!<\/code> \u043a\u0430\u043a <code>context_off = const CONTEXT_OFF<\/code>.<\/p>\n<p>\u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044e \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0441\u043b\u043e. \u042d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u0437 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Thread<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043b\u0435\u0436\u0430\u0442 \u043f\u043e\u043b\u044f.<\/p>\n<p><code>Thread<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043a\u0430\u043a <code>#[repr(C, align(64))]<\/code>, \u0438 <code>repr(C)<\/code> \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u0435\u043d: \u043e\u043d \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439. \u0423 <code>repr(Rust)<\/code> \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u043f\u0440\u0430\u0432\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044f \u043a\u0430\u043a \u0435\u043c\u0443 \u0443\u0434\u043e\u0431\u043d\u043e, \u0438 \u0442\u043e\u0433\u0434\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0435\u0445\u0430\u043b\u043e \u0431\u044b \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430.<\/p>\n<h3>\u0427\u0442\u043e \u043c\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0451 \u0441\u043b\u043e\u043c\u0430\u0442\u044c<\/h3>\n<p>\u0414\u0430\u0436\u0435 \u0441 <code>repr(C)<\/code> \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0451 \u0440\u0430\u0437\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u043b\u0447\u0430: \u043a\u0442\u043e-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <code>context<\/code> \u0443\u0435\u0437\u0436\u0430\u0435\u0442, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0448\u0435\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u0430\u043c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434 \u0432\u0441\u0442\u0430\u0432\u043a\u043e\u0439 \u0441\u0442\u043e\u044f\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:<\/p>\n<p>rust<\/p>\n<pre><code>const _: () = assert!(core::mem::size_of::&lt;Context&gt;() == 64);const _: () = assert!(core::mem::offset_of!(Context, r15) == 0, \"...\");const _: () = assert!(core::mem::offset_of!(Context, rip) == 48, \"...\");const _: () = assert!(core::mem::offset_of!(Context, rsp) == 56, \"...\");<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043c\u0435\u0449\u0435\u043d\u0438\u044f 0, 48 \u0438 56 \u044d\u0442\u043e \u0440\u043e\u0432\u043d\u043e \u0442\u0435 \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0440\u0443\u043a\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u0441\u0431\u043e\u0440\u043a\u0430 \u0443\u043f\u0430\u0434\u0451\u0442 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>\u042d\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0443\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 Rust \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u0441\u0442\u0440\u043e\u043a\u0443 <code>mov qword ptr [rdi + 48]<\/code>, \u0434\u043b\u044f \u043d\u0435\u0451 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u043a\u0441\u0442. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0438\u0441\u043b\u0430, \u0430 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u043c\u043e\u0435\u0439 \u0441\u043e\u0432\u0435\u0441\u0442\u0438.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u044c FPU \u043b\u0435\u0436\u0438\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043f\u043e\u043b\u0435\u043c<\/h3>\n<p>\u0412\u043e\u0442 \u0441\u0430\u043c\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<p>rust<\/p>\n<pre><code>#[repr(C, align(64))]pub struct Thread {    pub id: ThreadId,    pub state: ThreadState,    pub cpu_id: u32,    pub priority: u8,    pub ticks_used: u32,    pub kstack_top: u64,    pub kstack_phys: u64,    pub context: Context,    pub fpu: FpuArea,    _pad: [u8; 0],}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>FpuArea<\/code> \u044d\u0442\u043e \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442 \u043f\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 x87 \u0438 SSE, \u0438 \u043e\u043d \u0441\u0442\u043e\u0438\u0442 <strong>\u043f\u043e\u0441\u043b\u0435<\/strong> <code>context<\/code> \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u043e\u043b\u043e\u0436\u0438 \u044f \u0435\u0433\u043e \u0432\u044b\u0448\u0435, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <code>context<\/code> \u0441\u0434\u0432\u0438\u043d\u0443\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0430 1024 \u0431\u0430\u0439\u0442\u0430. \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0451\u0442 (\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u0436\u0435 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f), \u0430 \u0432\u043e\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u044b\u0448\u0435 \u043f\u043e\u0439\u043c\u0430\u044e\u0442 \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0438 \u0441\u0431\u043e\u0440\u043a\u0430 \u0443\u043f\u0430\u0434\u0451\u0442.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043a\u043e\u0441\u043c\u0435\u0442\u0438\u043a\u0430, \u0430 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u0441 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043e\u043c. \u0412 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0435 \u043d\u0430\u0434 \u043f\u043e\u043b\u0435\u043c <code>fpu<\/code> \u0441\u0442\u043e\u0438\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0440\u043e\u0432\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a (\u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u0433\u043e\u0434\u0430) \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u043b \u0435\u0433\u043e \u043c\u0430\u0448\u0438\u043d\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>\u0421\u0430\u043c\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c:<\/p>\n<p>rust<\/p>\n<pre><code>#[repr(C, align(64))]pub struct FpuArea {    bytes: [u8; FPU_AREA_SIZE],}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 64 \u0431\u0430\u0439\u0442\u0430 \u043d\u0435 \u044d\u0441\u0442\u0435\u0442\u0438\u043a\u0430, \u0430 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>XSAVE<\/code>: \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 64-\u0431\u0430\u0439\u0442\u043d\u043e \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u043c <strong>\u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c<\/strong> \u0430\u0434\u0440\u0435\u0441\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d \u0438 \u0441\u0430\u043c <code>Thread<\/code>, \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0442\u043e\u0436\u0435 \u043f\u043e 64-\u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443.<\/p>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0443\u043b\u044f\u043c\u0438, \u043a\u0440\u043e\u043c\u0435 \u0434\u0432\u0443\u0445 \u0431\u0430\u0439\u0442:<\/p>\n<p>rust<\/p>\n<pre><code>bytes[24] = 0x80; \/\/ MXCSR low bytebytes[25] = 0x1f; \/\/ MXCSR high byte -&gt; 0x1F80<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>0x1F80<\/code> \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 MXCSR \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e: \u0432\u0441\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f SSE \u0437\u0430\u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u044b. \u041d\u043e\u043b\u044c \u0442\u0430\u043c \u043e\u0437\u043d\u0430\u0447\u0430\u043b \u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0438 \u043f\u0435\u0440\u0432\u043e\u0435 \u0436\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435 \u0443\u043b\u0435\u0442\u0435\u043b\u043e \u0431\u044b \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.<\/p>\n<p>\u0410 <code>XSTATE_BV<\/code> \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0443\u043b\u0451\u043c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e. \u041f\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c <code>XRSTOR<\/code> \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e\u00bb, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0432\u0435\u0436\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0447\u0438\u0441\u0442\u044b\u0439 x87 \u0438 SSE \u0431\u0435\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044f \u0440\u0443\u043a\u0430\u043c\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u043b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:<\/p>\n<p>rust<\/p>\n<pre><code>const _: () = assert!(FPU_AREA_SIZE &gt;= kernel_arch_x86_64::xsave::XSAVE_X87_SSE_SIZE, \"...\");const _: () = assert!(FPU_AREA_SIZE.is_multiple_of(64), \"...\");<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0436\u0430\u0434\u043d\u044b\u043c: <code>XSAVE<\/code> \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u0438 <code>XRSTOR<\/code> \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u0431\u0435\u0437 \u043b\u0435\u043d\u0438\u0432\u044b\u0445 \u0441\u0445\u0435\u043c \u0441 \u043b\u043e\u0432\u043b\u0435\u0439 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a FPU. \u041b\u0435\u043d\u0438\u0432\u043e\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 FPU \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044e\u0442, \u043d\u043e \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0433\u043e\u043d\u043e\u043a \u043f\u0440\u0438 \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438. \u041c\u043d\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<h3>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432<\/h3>\n<p>\u041f\u043e\u043b\u043d\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0445\u0432\u043e\u0441\u0442\u0435 <code>schedule()<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>rust<\/p>\n<pre><code>    \/\/ Lock released - switch_context must follow immediately.    run_context_switch_hook(next, cpu_id);    #[cfg(target_os = \"none\")]    {        const FPU_MASK: u64 = kernel_arch_x86_64::xsave::XCR0_X87_SSE;        if !cur.is_null() {            unsafe { kernel_arch_x86_64::xsave::xsave64((*cur).fpu.as_mut_ptr(), FPU_MASK) };        }        unsafe { kernel_arch_x86_64::xsave::xrstor64((*next).fpu.as_ptr(), FPU_MASK) };    }    if cur.is_null() {        unsafe { switch::switch_first(next) };    } else {        unsafe { switch::switch_context(cur, next) };    }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e, \u043f\u043e\u0442\u043e\u043c FPU, \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b. \u0412\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u0445.<\/p>\n<p>\u0425\u0443\u043a \u043d\u0443\u0436\u0435\u043d \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u041e\u043d \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438, \u0430 \u0430\u0434\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0436\u0438\u0432\u0443\u0442 \u044d\u0442\u0430\u0436\u043e\u043c \u0432\u044b\u0448\u0435, \u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043b\u0431\u044d\u043a.<\/p>\n<h3>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e<\/h3>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0445\u0443\u043a\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n<p>rust<\/p>\n<pre><code>pub(crate) unsafe fn activate_address_space(new_as: *mut AddressSpace, cpu_id: u32) {    let slot = &amp;CPU_CURRENT_AS[cpu_id as usize % MAX_CPUS];    let old_as = slot.load(Ordering::Acquire) as *mut AddressSpace;    if old_as == new_as {        return;    }    unsafe { (*new_as).active_cpus.mark_active(cpu_id) };    slot.store(new_as as usize, Ordering::Release);    unsafe { (*new_as).activate() };   \/\/ \u0437\u0434\u0435\u0441\u044c \u043f\u0438\u0448\u0435\u0442\u0441\u044f CR3    if !old_as.is_null() {        unsafe { (*old_as).active_cpus.mark_inactive(cpu_id) };    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a: \u043d\u043e\u0432\u043e\u0435 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c <strong>\u0434\u043e<\/strong> \u0437\u0430\u043f\u0438\u0441\u0438 CR3, \u0430 \u0441\u0442\u0430\u0440\u043e\u0435 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c <strong>\u043f\u043e\u0441\u043b\u0435<\/strong>.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e <code>active_cpus<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 TLB: \u043a\u043e\u0433\u0434\u0430 \u0433\u0434\u0435-\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u043e\u0441\u043b\u0430\u0442\u044c \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c \u044f\u0434\u0440\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u0442\u043e \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442. \u0415\u0441\u043b\u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u043e\u0435 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0440\u0430\u043d\u044c\u0448\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 CR3, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f\u0434\u0440\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0440\u044b\u043c CR3, \u043d\u043e \u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0435\u0433\u043e \u0443\u0436\u0435 \u043d\u0435\u0442. \u041f\u0440\u0438\u0448\u0435\u0434\u0448\u0430\u044f \u0432 \u044d\u0442\u043e \u043e\u043a\u043d\u043e \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043e\u0431\u043e\u0439\u0434\u0451\u0442 \u043d\u0430\u0441 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439, \u0438 \u0432 TLB \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<p>\u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u0430\u0451\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u044f\u0434\u0440\u043e \u0447\u0438\u0441\u043b\u0438\u0442\u0441\u044f \u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445 \u0441\u0440\u0430\u0437\u0443. \u042d\u0442\u043e \u043b\u0438\u0448\u043d\u0435\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u041f\u043e\u0442\u0435\u0440\u044f\u043d\u043d\u0430\u044f \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u044d\u0442\u043e \u0442\u0438\u0445\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u0430\u044f \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430. \u041c\u0435\u0436\u0434\u0443 \u00ab\u0438\u043d\u043e\u0433\u0434\u0430 \u043b\u0438\u0448\u043d\u0438\u0439 IPI\u00bb \u0438 \u00ab\u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u00bb \u0432\u044b\u0431\u043e\u0440 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d.<\/p>\n<p>\u0418 \u0437\u0430\u043e\u0434\u043d\u043e \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435 \u0443\u0436\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0438: CR3 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 <code>switch_context<\/code>, \u0430 \u0434\u043e \u043d\u0435\u0433\u043e.<\/p>\n<p>\u0427\u0438\u0441\u0442\u043e \u044f\u0434\u0435\u0440\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 (idle \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435) \u044d\u0442\u043e\u0442 \u043f\u0443\u0442\u044c \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442: \u0441\u0432\u043e\u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0443 \u043d\u0438\u0445 \u043d\u0435\u0442, \u0430 \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u044f\u0434\u0440\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0430 \u0432\u043e \u0432\u0441\u0435\u0445 PML4, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 CR3 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h3>\u0427\u0435\u0433\u043e \u044f \u0442\u0443\u0442 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e<\/h3>\n<p>\u0420\u0430\u0437 \u0443\u0436 \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u0430\u0436\u0443 \u0438 \u043f\u0440\u043e \u0435\u0451 \u043f\u0440\u0435\u0434\u0435\u043b\u044b.<\/p>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0451\u0445 \u0432\u0435\u0449\u0430\u0445: <code>repr(C)<\/code>, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u0445 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u044f \u043d\u0435 \u043e\u0448\u0438\u0431\u0441\u044f, \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0447\u0438\u0441\u043b\u0430 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440. \u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0422\u0440\u0435\u0442\u044c\u044e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0438\u043a\u0442\u043e.<\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 <code>mov qword ptr [rdi + {context_off} + 32], rbx<\/code> \u0438 \u043f\u043e\u043b\u0435\u043c <code>rbx<\/code> \u043f\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e 32 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u044f \u0442\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043b. \u041f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u0439 \u044f \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u0441\u0451 \u0441\u043e\u0431\u0435\u0440\u0451\u0442\u0441\u044f, \u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435: FPU-\u0432\u0435\u0442\u043a\u0430 \u0438\u0434\u0451\u0442 \u043f\u043e\u0434 <code>#[cfg(target_os = \"none\")]<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430 \u0445\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435, \u0433\u0434\u0435 \u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u0435\u0441\u0442\u044b \u043b\u043e\u0433\u0438\u043a\u0438, \u0435\u0451 \u043d\u0435\u0442 \u0432\u043e\u0432\u0441\u0435, \u0442\u0430\u043c <code>switch_context<\/code> \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430. \u0417\u043d\u0430\u0447\u0438\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0432 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435. \u0423 \u043c\u0435\u043d\u044f \u0434\u043b\u044f \u043d\u0435\u0451 \u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442, \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u044f \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0437\u043d\u0430\u044e: \u0435\u0441\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c <code>XSAVE<\/code>, \u043e\u043d \u043f\u0430\u0434\u0430\u0435\u0442. \u0422\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u0447\u0438\u043d\u043a\u0438, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442.<\/p>\n<p>\u041a\u043e\u0434 \u043e\u0442\u043a\u0440\u044b\u0442, \u043f\u0438\u0441\u0430\u043b \u043e\u0434\u0438\u043d, \u0441\u0442\u0430\u0434\u0438\u044f \u0440\u0430\u043d\u043d\u044f\u044f: <a href=\"https:\/\/github.com\/ScioFuturum\/rumicos\" rel=\"noopener noreferrer nofollow\">github.com\/ScioFuturum\/rumicos<\/a><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u044b\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435. \u042d\u0442\u043e \u0440\u043e\u0432\u043d\u043e \u0442\u043e\u0442 \u043a\u043e\u0434, \u0433\u0434\u0435 \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043c, \u0433\u0434\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u0430.<\/p>\n<\/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\/articles\/1068066\/\">https:\/\/habr.com\/ru\/articles\/1068066\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u044f \u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 \u0442\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u0422\u0430\u043a \u0438 \u0435\u0441\u0442\u044c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u043e \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0438 \u043c\u0435\u043d\u044c\u0448\u0435: \u043a\u0430\u043a \u0432 \u043c\u043e\u0451\u043c \u044f\u0434\u0440\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0442\u0430\u043c \u0437\u043d\u0430\u0435\u0442 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 Rust.\u042d\u0442\u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u044c. \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0443 \u043d\u0443\u0436\u0435\u043d \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c, \u0430 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0415\u0441\u043b\u0438 \u044d\u0442\u0438 \u0434\u0432\u043e\u0435 \u0440\u0430\u0437\u043e\u0439\u0434\u0443\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u0435\u043d\u0438\u044f\u0445, \u0432\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0412\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u044f\u0434\u0440\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0438\u0448\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043c\u0438\u043c\u043e \u0438 \u043f\u0430\u0434\u0430\u0435\u0442 \u0433\u0434\u0435-\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u043c\u0435\u0441\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0438.\u0421\u0430\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044casmswitch_context:    .byte 0xf3, 0x0f, 0x1e, 0xfa    mov qword ptr [rdi + {context_off} + 0],  r15    mov qword ptr [rdi + {context_off} + 8],  r14    mov qword ptr [rdi + {context_off} + 16], r13    mov qword ptr [rdi + {context_off} + 24], r12    mov qword ptr [rdi + {context_off} + 32], rbx    mov qword ptr [rdi + {context_off} + 40], rbp    lea rax, [rip + .Lswitch_return]    mov qword ptr [rdi + {context_off} + 48], rax    mov qword ptr [rdi + {context_off} + 56], rsp    mov r15, qword ptr [rsi + {context_off} + 0]    mov r14, qword ptr [rsi + {context_off} + 8]    mov r13, qword ptr [rsi + {context_off} + 16]    mov r12, qword ptr [rsi + {context_off} + 24]    mov rbx, qword ptr [rsi + {context_off} + 32]    mov rbp, qword ptr [rsi + {context_off} + 40]    mov rsp, qword ptr [rsi + {context_off} + 56]    jmp qword ptr [rsi + {context_off} + 48].Lswitch_return:    ret\u0414\u0432\u0430\u0434\u0446\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0438 \u0432 \u043d\u0438\u0445 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u0441\u043c\u0435\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. rdi \u044d\u0442\u043e \u0443\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a, rsi \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0439, \u0442\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442 System V ABI.\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u044d\u0442\u043e endbr64, \u043c\u0435\u0442\u043a\u0430 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439 \u0446\u0435\u043b\u0438 \u043d\u0435\u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0434\u043b\u044f Intel CET. \u0417\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0431\u0430\u0439\u0442\u0430\u043c\u0438.\u041f\u043e\u0447\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0432\u0441\u0435\u0433\u043e \u0448\u0435\u0441\u0442\u044c\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0434\u0430\u044e\u0442: \u0433\u0434\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b? \u0413\u0434\u0435 rax, rcx, rdx, \u0433\u0434\u0435 \u0432\u0441\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430?\u0418\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0438 \u044d\u0442\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u0430 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043e \u0432\u044b\u0437\u043e\u0432\u0430\u0445. \u041f\u043e System V \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0430 \u043b\u0430\u0433\u0435\u0440\u044f. Callee-saved (rbx, rbp, r12\u2013r15) \u043e\u0431\u044f\u0437\u0430\u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. Caller-saved \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435, \u0438 \u043e \u043d\u0438\u0445 \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430.switch_context \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 Rust \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0417\u043d\u0430\u0447\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0443\u0436\u0435 \u0441\u0430\u043c \u0440\u0430\u0441\u0441\u0442\u0430\u0432\u0438\u043b \u0432\u043e\u043a\u0440\u0443\u0433 \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u0431\u044b\u043b\u043e \u0434\u043e\u0440\u043e\u0433\u043e \u0438\u0437 caller-saved. \u0415\u0441\u043b\u0438 \u0431\u044b \u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b \u0438\u0445 \u0435\u0449\u0451 \u0440\u0430\u0437, \u044f \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440.\u041e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0448\u0435\u0441\u0442\u044c callee-saved \u043f\u043b\u044e\u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u0442\u0435\u043a\u0430 \u0438 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430. \u0412\u043e\u0441\u0435\u043c\u044c \u043f\u043e \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442, \u0440\u043e\u0432\u043d\u043e 64:rust#[repr(C)]#[derive(Clone, Copy)]pub struct Context {    pub r15: u64,    pub r14: u64,    pub r13: u64,    pub r12: u64,    pub rbx: u64,    pub rbp: u64,    pub rip: u64,    pub rsp: u64,}\u041f\u043e\u0447\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0443\u043a\u0430\u043c\u0438\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435:asm    lea rax, [rip + .Lswitch_return]    mov qword ptr [rdi + {context_off} + 48], rax\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0435\u0440\u0451\u0442 \u0430\u0434\u0440\u0435\u0441 \u043c\u0435\u0442\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0438 \u043a\u043b\u0430\u0434\u0451\u0442 \u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u0435 rip \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. \u0410 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 ret, \u0430 \u043f\u0440\u044b\u0436\u043a\u043e\u043c \u043f\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u043c\u0443 rip \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e:asm    jmp qword ptr [rsi + {context_off} + 48]\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 ret \u0432\u0435\u0440\u043d\u0443\u043b \u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0443\u0434\u0430, \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u0448\u043b\u0438, \u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u043e\u0432\u043d\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0435: \u0443\u0439\u0442\u0438 \u0442\u0443\u0434\u0430, \u0433\u0434\u0435 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a. \u0421\u0442\u0435\u043a \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0432\u044b\u0448\u0435, \u0442\u0430\u043a \u0447\u0442\u043e ret \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u0431\u044b \u043f\u043e \u0447\u0443\u0436\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430, \u0438 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u044b \u043f\u043e\u0447\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u044b \u0432\u043e\u0432\u0441\u0435.\u041c\u0435\u0442\u043a\u0430 .Lswitch_return \u044d\u0442\u043e \u0442\u043e\u0447\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0442\u043e\u043a \u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u044f\u0442. \u0422\u0430\u043c \u0441\u0442\u043e\u0438\u0442 ret, \u0438 \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0442\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u044e\u0434\u0430 \u043f\u0440\u044b\u0433\u043d\u0435\u0442. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e: \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 jmp \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 ret, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438.\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0435\u0441\u0442\u044c switch_first \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u0430: \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043d\u0435\u0447\u0435\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 next.\u0422\u0430 \u0441\u0430\u043c\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430{context_off} \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u043e\u0442\u0441\u044e\u0434\u0430:rustpub const CONTEXT_OFF: usize = core::mem::offset_of!(Thread, context);\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 global_asm! \u043a\u0430\u043a context_off = const CONTEXT_OFF.\u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u043b\u044e \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0441\u043b\u043e. \u042d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u0437 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Thread. \u0422\u043e \u0435\u0441\u0442\u044c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043b\u0435\u0436\u0430\u0442 \u043f\u043e\u043b\u044f.Thread \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043a\u0430\u043a #[repr(C, align(64))], \u0438 repr(C) \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u0435\u043d: \u043e\u043d \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439. \u0423 repr(Rust) \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u043f\u0440\u0430\u0432\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044f \u043a\u0430\u043a \u0435\u043c\u0443 \u0443\u0434\u043e\u0431\u043d\u043e, \u0438 \u0442\u043e\u0433\u0434\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0435\u0445\u0430\u043b\u043e \u0431\u044b \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430.\u0427\u0442\u043e \u043c\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0451 \u0441\u043b\u043e\u043c\u0430\u0442\u044c\u0414\u0430\u0436\u0435 \u0441 repr(C) \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0451 \u0440\u0430\u0437\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u043b\u0447\u0430: \u043a\u0442\u043e-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 context \u0443\u0435\u0437\u0436\u0430\u0435\u0442, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0448\u0435\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u0430\u043c.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434 \u0432\u0441\u0442\u0430\u0432\u043a\u043e\u0439 \u0441\u0442\u043e\u044f\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:rustconst _: () = assert!(core::mem::size_of::&lt;Context&gt;() == 64);const _: () = assert!(core::mem::offset_of!(Context, r15) == 0, &#171;&#8230;&#187;);const _: () = assert!(core::mem::offset_of!(Context, rip) == 48, &#171;&#8230;&#187;);const _: () = assert!(core::mem::offset_of!(Context, rsp) == 56, &#171;&#8230;&#187;);\u0421\u043c\u0435\u0449\u0435\u043d\u0438\u044f 0, 48 \u0438 56 \u044d\u0442\u043e \u0440\u043e\u0432\u043d\u043e \u0442\u0435 \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0440\u0443\u043a\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u0441\u0431\u043e\u0440\u043a\u0430 \u0443\u043f\u0430\u0434\u0451\u0442 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f.\u042d\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0443\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 Rust \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u0441\u0442\u0440\u043e\u043a\u0443 mov qword ptr [rdi + 48], \u0434\u043b\u044f \u043d\u0435\u0451 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u043a\u0441\u0442. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0438\u0441\u043b\u0430, \u0430 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u043c\u043e\u0435\u0439 \u0441\u043e\u0432\u0435\u0441\u0442\u0438.\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u044c FPU \u043b\u0435\u0436\u0438\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043f\u043e\u043b\u0435\u043c\u0412\u043e\u0442 \u0441\u0430\u043c\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:rust#[repr(C, align(64))]pub struct Thread {    pub id: ThreadId,    pub state: ThreadState,    pub cpu_id: u32,    pub priority: u8,    pub ticks_used: u32,    pub kstack_top: u64,    pub kstack_phys: u64,    pub context: Context,    pub fpu: FpuArea,    _pad: [u8; 0],}FpuArea \u044d\u0442\u043e \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442 \u043f\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 x87 \u0438 SSE, \u0438 \u043e\u043d \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0441\u043b\u0435 context \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u043e\u043b\u043e\u0436\u0438 \u044f \u0435\u0433\u043e \u0432\u044b\u0448\u0435, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 context \u0441\u0434\u0432\u0438\u043d\u0443\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0430 1024 \u0431\u0430\u0439\u0442\u0430. \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0451\u0442 (\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u0436\u0435 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f), \u0430 \u0432\u043e\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u044b\u0448\u0435 \u043f\u043e\u0439\u043c\u0430\u044e\u0442 \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0438 \u0441\u0431\u043e\u0440\u043a\u0430 \u0443\u043f\u0430\u0434\u0451\u0442.\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043a\u043e\u0441\u043c\u0435\u0442\u0438\u043a\u0430, \u0430 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u0441 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043e\u043c. \u0412 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0435 \u043d\u0430\u0434 \u043f\u043e\u043b\u0435\u043c fpu \u0441\u0442\u043e\u0438\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0440\u043e\u0432\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a (\u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u0433\u043e\u0434\u0430) \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u043b \u0435\u0433\u043e \u043c\u0430\u0448\u0438\u043d\u0430\u043b\u044c\u043d\u043e.\u0421\u0430\u043c\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c:rust#[repr(C, align(64))]pub struct FpuArea {    bytes: [u8; FPU_AREA_SIZE],}\u0412\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 64 \u0431\u0430\u0439\u0442\u0430 \u043d\u0435 \u044d\u0441\u0442\u0435\u0442\u0438\u043a\u0430, \u0430 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 XSAVE: \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 64-\u0431\u0430\u0439\u0442\u043d\u043e \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u043c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d \u0438 \u0441\u0430\u043c Thread, \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0442\u043e\u0436\u0435 \u043f\u043e 64-\u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443.\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0443\u043b\u044f\u043c\u0438, \u043a\u0440\u043e\u043c\u0435 \u0434\u0432\u0443\u0445 \u0431\u0430\u0439\u0442:rustbytes[24] = 0x80; \/\/ MXCSR low bytebytes[25] = 0x1f; \/\/ MXCSR high byte -&gt; 0x1F800x1F80 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 MXCSR \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e: \u0432\u0441\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f SSE \u0437\u0430\u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u044b. \u041d\u043e\u043b\u044c \u0442\u0430\u043c \u043e\u0437\u043d\u0430\u0447\u0430\u043b \u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0438 \u043f\u0435\u0440\u0432\u043e\u0435 \u0436\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435 \u0443\u043b\u0435\u0442\u0435\u043b\u043e \u0431\u044b \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a.\u0410 XSTATE_BV \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0443\u043b\u0451\u043c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e. \u041f\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c XRSTOR \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e\u00bb, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0432\u0435\u0436\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0447\u0438\u0441\u0442\u044b\u0439 x87 \u0438 SSE \u0431\u0435\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044f \u0440\u0443\u043a\u0430\u043c\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u043b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.\u0420\u0430\u0437\u043c\u0435\u0440 \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:rustconst _: () = assert!(FPU_AREA_SIZE &gt;= kernel_arch_x86_64::xsave::XSAVE_X87_SSE_SIZE, &#171;&#8230;&#187;);const _: () = assert!(FPU_AREA_SIZE.is_multiple_of(64), &#171;&#8230;&#187;);\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0436\u0430\u0434\u043d\u044b\u043c: XSAVE \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u0438 XRSTOR \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u0431\u0435\u0437 \u043b\u0435\u043d\u0438\u0432\u044b\u0445 \u0441\u0445\u0435\u043c \u0441 \u043b\u043e\u0432\u043b\u0435\u0439 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a FPU. \u041b\u0435\u043d\u0438\u0432\u043e\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 FPU \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044e\u0442, \u043d\u043e \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0433\u043e\u043d\u043e\u043a \u043f\u0440\u0438 \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438. \u041c\u043d\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c.\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432\u041f\u043e\u043b\u043d\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0445\u0432\u043e\u0441\u0442\u0435 schedule() \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:rust    \/\/ Lock released &#8212; switch_context must follow immediately.    run_context_switch_hook(next, cpu_id);    #[cfg(target_os = &#171;none&#187;)]    {        const FPU_MASK: u64 = kernel_arch_x86_64::xsave::XCR0_X87_SSE;        if !cur.is_null() {            unsafe { kernel_arch_x86_64::xsave::xsave64((*cur).fpu.as_mut_ptr(), FPU_MASK) };        }        unsafe { kernel_arch_x86_64::xsave::xrstor64((*next).fpu.as_ptr(), FPU_MASK) };    }    if cur.is_null() {        unsafe { switch::switch_first(next) };    } else {        unsafe { switch::switch_context(cur, next) };    }\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e, \u043f\u043e\u0442\u043e\u043c FPU, \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b. \u0412\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u0445.\u0425\u0443\u043a \u043d\u0443\u0436\u0435\u043d \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u041e\u043d \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438, \u0430 \u0430\u0434\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0436\u0438\u0432\u0443\u0442 \u044d\u0442\u0430\u0436\u043e\u043c \u0432\u044b\u0448\u0435, \u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043b\u0431\u044d\u043a.\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e\u0412\u043d\u0443\u0442\u0440\u0438 \u0445\u0443\u043a\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u044d\u0442\u043e:rustpub(crate) unsafe fn activate_address_space(new_as: *mut AddressSpace, cpu_id: u32) {    let slot = &amp;CPU_CURRENT_AS[cpu_id as usize % MAX_CPUS];    let old_as = slot.load(Ordering::Acquire) as *mut AddressSpace;    if old_as == new_as {        return;    }    unsafe { (*new_as).active_cpus.mark_active(cpu_id) };    slot.store(new_as as usize, Ordering::Release);    unsafe { (*new_as).activate() };   \/\/ \u0437\u0434\u0435\u0441\u044c \u043f\u0438\u0448\u0435\u0442\u0441\u044f CR3    if !old_as.is_null() {        unsafe { (*old_as).active_cpus.mark_inactive(cpu_id) };    }}\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a: \u043d\u043e\u0432\u043e\u0435 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0434\u043e \u0437\u0430\u043f\u0438\u0441\u0438 CR3, \u0430 \u0441\u0442\u0430\u0440\u043e\u0435 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u043e\u0441\u043b\u0435.\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e active_cpus \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 TLB: \u043a\u043e\u0433\u0434\u0430 \u0433\u0434\u0435-\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u043e\u0441\u043b\u0430\u0442\u044c \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c \u044f\u0434\u0440\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u0442\u043e \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442. \u0415\u0441\u043b\u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u043e\u0435 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0440\u0430\u043d\u044c\u0448\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 CR3, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f\u0434\u0440\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0440\u044b\u043c CR3, \u043d\u043e \u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0435\u0433\u043e \u0443\u0436\u0435 \u043d\u0435\u0442. \u041f\u0440\u0438\u0448\u0435\u0434\u0448\u0430\u044f \u0432 \u044d\u0442\u043e \u043e\u043a\u043d\u043e \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043e\u0431\u043e\u0439\u0434\u0451\u0442 \u043d\u0430\u0441 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439, \u0438 \u0432 TLB \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c.\u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u0430\u0451\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u044f\u0434\u0440\u043e \u0447\u0438\u0441\u043b\u0438\u0442\u0441\u044f \u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445 \u0441\u0440\u0430\u0437\u0443. \u042d\u0442\u043e \u043b\u0438\u0448\u043d\u0435\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u041f\u043e\u0442\u0435\u0440\u044f\u043d\u043d\u0430\u044f \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u044d\u0442\u043e \u0442\u0438\u0445\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u0430\u044f \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430. \u041c\u0435\u0436\u0434\u0443 \u00ab\u0438\u043d\u043e\u0433\u0434\u0430 \u043b\u0438\u0448\u043d\u0438\u0439 IPI\u00bb \u0438 \u00ab\u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u00bb \u0432\u044b\u0431\u043e\u0440 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d.\u0418 \u0437\u0430\u043e\u0434\u043d\u043e \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-490204","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/490204","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=490204"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/490204\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=490204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=490204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=490204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}