{"id":901,"date":"2020-11-04T14:15:34","date_gmt":"2020-11-04T06:15:34","guid":{"rendered":"http:\/\/www.wangkaixuan.tech\/?p=901"},"modified":"2025-01-08T13:51:28","modified_gmt":"2025-01-08T05:51:28","slug":"linux%e6%97%b6%e9%92%9f%e7%b3%bb%e5%88%97-00-rdtsc%e7%9a%84%e5%9d%91","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=901","title":{"rendered":"Linux\u65f6\u949f\u7cfb\u5217-00-\u7ec6\u8bf4RDTSC\u7684\u5751"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1.\u524d\u8a00<\/h2>\n\n\n\n<p>\u524d\u51e0\u5929\u5199\u4e86\u4e00\u7bc7\u6587\u7ae0\uff08<a href=\"http:\/\/www.wangkaixuan.tech\/?p=840\">\u94fe\u63a5\u5728\u6b64<\/a>\uff09\uff0c\u63a2\u7d22\u5404\u79cd\u53d6\u65f6\u95f4\u7684\u65b9\u5f0f\uff0c\u7ed3\u8bba\u662fTSC\u662f\u7cbe\u5ea6\u6700\u9ad8\u3001\u5f00\u9500\u6700\u5c0f\u7684\u65b9\u5f0f\uff0c\u4f46\u662f\u540c\u65f6\u4e5f\u58f0\u660e\u4e86\uff0c\u4f7f\u7528\u7684\u65f6\u5019\u53ef\u80fd\u4f1a\u78b0\u89c1\u5f88\u591a\u5751\u3002<\/p>\n\n\n\n<p>\u4eca\u5929\u6211\u4eec\u5c06\u8fdb\u884c\u6df1\u5165\u63a2\u8ba8\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.TSC\u539f\u7406<\/h2>\n\n\n\n<p>TSC\u662f\u4e00\u4e2a64\u4f4d\u7684\u5bc4\u5b58\u5668\uff0c\u4eceIntel Pentium\u5f00\u59cb\uff0c\u5728\u6240\u6709\u7684x86\u5e73\u53f0\u4e0a\u5747\u4f1a\u63d0\u4f9b\u3002\u5b83\u5b58\u653e\u7684\u662fCPU\u4ece\u542f\u52a8\u4ee5\u6765\u6267\u884c\u7684\u6307\u4ee4\u5468\u671f\u6570\u3002\u901a\u8fc7rdtsc\u6307\u4ee4\uff0c\u53ef\u4ee5\u5c06TSC\u7684\u6570\u503c\u5b58\u653e\u5728EDX:EAX\u4e2d\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uint64_t get_tsc()\n{\n    uint64_t a, d;\n    __asm__ volatile(\"rdtsc\" : \"=a\"(a), \"=d\"(d));\n    return (d &lt;&lt; 32) | a;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3.TSC\u7684\u5751<\/h2>\n\n\n\n<p>TSC\u66fe\u7ecf\u662f\u4e00\u4e2a\u6781\u9ad8\u7cbe\u5ea6\uff0c\u6781\u4f4e\u5f00\u9500\u7684\u53d6\u65f6\u95f4\u7684\u65b9\u6cd5\uff0c\u4f46\u662f\u968f\u7740CPU\u5f80\u591a\u6838\u3001\u591a\u5904\u7406\u5668\u3001\u4f4e\u529f\u8017\u7684\u65b9\u5411\u4e0a\u8d70\uff0c\u5728\u4f7f\u7528TSC\u65f6\u5c31\u4f1a\u9047\u5230\u5f88\u591a\u5751\u3002<\/p>\n\n\n\n<p>\u3010<strong>\u57511<\/strong>\u3011\u6bd4\u5982\u6709\u7684CPU\u4f1a\u6839\u636e\u673a\u5668\u8d1f\u8f7d\u60c5\u51b5\u52a8\u6001\u8c03\u8282\u5de5\u4f5c\u9891\u7387\uff0c \u90a3\u4e48\u5355\u4f4d\u65f6\u95f4CPU\u7684\u6307\u4ee4\u5468\u671f\u6570\u5c31\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u4e5f\u5c31\u5f88\u96be\u5c06\u5176\u8f6c\u6362\u6210\u65f6\u95f4\u3002\u53e6\u5916\uff0cCPU\u8fdb\u5165\u4f11\u7720\u518d\u6b21\u91cd\u542f\u540e\uff0cTSC\u4f1a\u6e05\u96f6\u3002<\/p>\n\n\n\n<p>\u3010<strong>\u57512<\/strong>\u3011\u518d\u6bd4\u5982\uff0c\u5728\u540c\u4e00\u5904\u7406\u5668\u7684\u591a\u4e2a\u6838\u5fc3\u4e4b\u95f4\uff0c\u4ee5\u53ca\u4e0d\u540c\u5904\u7406\u5668\u7684\u4e0d\u540c\u6838\u5fc3\u4e4b\u95f4\uff0crdtsc\u7684\u7ed3\u679c\u662f\u5426\u662f\u540c\u6b65\u7684\u5462\uff1f\u5982\u679c\u4e0d\u540c\u6b65\uff0c\u90a3\u4e48\u53d6\u65f6\u7684\u7ed3\u679c\u5c31\u4e0d\u80fd\u7528\u6765\u76f8\u4e92\u6bd4\u8f83\u3002<\/p>\n\n\n\n<p>\u3010<strong>\u57513<\/strong>\u3011\u518d\u6bd4\u5982\uff0cIntel\u7684\u5904\u7406\u5668\u81eaPentium Pro\u5f00\u59cb\uff0c\u5f15\u5165\u4e86\u4e71\u5e8f\u6267\u884c\u7684\u529f\u80fd\uff0c\u5bfc\u81f4\u7a0b\u5e8f\u8bfb\u53d6\u7684TSC\u7ed3\u679c\u53ef\u80fd\u4e0d\u51c6\u3002\u5982\u679c\u7f16\u5199\u6d4b\u8bd5\u7a0b\u5e8f\u7684\u65f6\u5019\u6ca1\u6709\u4e3b\u52a8\u56de\u907f\uff0c\u4e5f\u53ef\u80fd\u4f1a\u6389\u5230\u5751\u91cc\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4.\u5b98\u65b9\u586b\u5751<\/h2>\n\n\n\n<p>\u5728\u8f83\u65b0\u7248\u672c\u7684CPU\u4e2d\uff0c\u5f15\u5165\u4e86\u5e38\u91cf\u901f\u7387TSC\u7684\u7279\u6027\uff08constant rate TSC\uff09\u3002\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u67e5\u770b\u4f60\u7684CPU\u662f\u5426\u652f\u6301(\u6211\u7684\u673a\u5668\u6709\u56db\u4e2a\u6838\uff0c\u56e0\u6b64\u8f93\u51fa\u4e86\u56db\u6761)\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"456\" src=\"http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/11\/image-35.png\" alt=\"\" class=\"wp-image-903\"\/><\/figure>\n\n\n\n<p>\u652f\u6301\u8be5\u7279\u6027\u7684CPU\uff0c\u5176TSC\u662f\u6309\u7167\u5176\u6807\u79f0\u9891\u7387\u6d41\u901d\u7684\uff0c\u4e0eCPU\u7684\u5b9e\u9645\u5de5\u4f5c\u9891\u7387\u4e0e\u72b6\u6001\u65e0\u5173\u3002\u5982\u679c\u4f60\u7684CPU\u4e5f\u662f\u652f\u6301constant_tsc\u7279\u6027\u7684\uff0c\u90a3\u4e48\u3010<strong>\u57511<\/strong>\u3011\u7b97\u662f\u586b\u4e0a\u4e86\u3002<\/p>\n\n\n\n<p>\u5173\u4e8e\u3010<strong>\u57512<\/strong>\u3011\uff0c\u5373\u4e0d\u540c\u6838\u5fc3\u8bfb\u53d6\u7684tsc\u662f\u5426\u540c\u6b65\uff0c\u76ee\u524d\u6ca1\u6709\u627e\u5230\u7edf\u4e00\u7684\u8bf4\u6cd5\uff0cIntel\u7684\u5b98\u65b9\u624b\u518c\u4e5f\u6ca1\u6709\u660e\u8bf4\uff0c\u6bd4\u5982\uff1a<strong>vol 3b\uff0c17.15.1 Invariant TSC\u7ae0\u8282<\/strong>\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>The time stamp counter in newer processors may support an enhancement, referred to as invariant TSC.<br>Processor\u2019s support for invariant TSC is indicated by CPUID.80000007H:EDX[8].<br>The invariant TSC will run at a constant rate in all ACPI P-, C-. and T-states. This is the architectural behavior<br>moving forward. On processors with invariant TSC support, the OS may use the TSC for wall clock timer services<br>(instead of ACPI or HPET timers). TSC reads are much more efficient and do not incur the overhead associated with<br>a ring transition or access to a platform resource.<\/p><\/blockquote>\n\n\n\n<p>\u4f46\u8fd9\u91cc\u9762\u53ea\u662f\u8bf4TSC\u80fd\u591f\u5728CPU\u5904\u4e8e\u4efb\u4f55(\u7535\u6e90)\u72b6\u6001\u4e0b\u90fd\u80fd\u4fdd\u8bc1\u4ee5\u6807\u79f0\u901f\u7387\u9012\u589e\uff0c\u5e76\u6ca1\u6709\u660e\u786e\u8bf4\u660eTSC\u80fd\u591f\u5728\u591a\u6838\u751a\u81f3\u591a\u5904\u7406\u5668\u7684\u60c5\u51b5\u4e0b\u4fdd\u6301\u540c\u6b65\u3002<\/p>\n\n\n\n<p>\u53e6\u4e00\u4e2a\u86db\u4e1d\u9a6c\u8ff9\u662f\u5728Linux\u5185\u6838\u4ee3\u7801\u4e2d\uff08<a href=\"https:\/\/github.com\/torvalds\/linux\/blob\/master\/arch\/x86\/kernel\/tsc.c\">\u94fe\u63a5\u5728\u6b64<\/a>\uff09:<\/p>\n\n\n\n<p>\u8fd9\u91cc\u6709\u4e00\u4e2aunsynchronized_tsc()\u51fd\u6570\uff0c\u7528\u4e8e\u5224\u65ad\u7cfb\u7edf\u7684TSC\u662f\u4e0d\u662f\u540c\u6b65\u7684\uff0c\u4ee3\u7801\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n * Make an educated guess if the TSC is trustworthy and synchronized\n * over all CPUs.\n *\/\nint unsynchronized_tsc(void)\n{\n\tif (!boot_cpu_has(X86_FEATURE_TSC) || tsc_unstable)\n\t\treturn 1;\n\n#ifdef CONFIG_SMP\n\tif (apic_is_clustered_box())\n\t\treturn 1;\n#endif\n\n\tif (boot_cpu_has(X86_FEATURE_CONSTANT_TSC))\n\t\treturn 0;\n\n\tif (tsc_clocksource_reliable)\n\t\treturn 0;\n\t\/*\n\t * Intel systems are normally all synchronized.\n\t * Exceptions must mark TSC as unstable:\n\t *\/\n\tif (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {\n\t\t\/* assume multi socket systems are not synchronized: *\/\n\t\tif (num_possible_cpus() > 1)\n\t\t\treturn 1;\n\t}\n\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6709\u51e0\u4e2a\u6709\u610f\u601d\u7684\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f00\u5934\u7684\u6ce8\u91ca\u8bf4\uff0c\u201cmake an educated guess\u201d\uff0c\u5373\u6709\u6839\u636e\u7684<strong>\u731c\u6d4b<\/strong>\uff0c\u5373\u8fd9\u91cc\u662f\u4e0d\u662fTSC\u540c\u6b65\u7684\u5224\u65ad\u4f9d\u7136\u662f\u4e00\u4e2a\u731c\u6d4b<\/li><li>\u4e2d\u95f4\u7684\u4ee3\u7801\u5224\u65ad\u4e86\u662f\u5426\u5f00\u542f\u4e86CONSTANT TSC\u7279\u6027\uff0c\u5982\u679c\u5f00\u542f\u5c31\u76f4\u63a5\u8fd4\u56de0\uff0c\u5373TSC\u662f\u540c\u6b65\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ea\u8981\u6211\u4eec\u5728cpuinfo\u91cc\u770b\u5230constant_tsc\u7684flag\uff0c\u5c31\u8bc1\u660e\u6211\u4eec\u7684\u673a\u5668\u7684TSC\u662f\u540c\u6b65\u7684<\/li><li>\u540e\u9762\u8fd8\u6709\u4e00\u53e5\u6ce8\u91ca\u201cIntel systems are normally all synchronized.Exceptions must mark TSC as unstable:\u201d\uff0c\u5373Intel\u7684\u7cfb\u7edf\uff0c\u53ea\u8981\u7528\u6237\u6ca1\u6709\u624b\u52a8\u7981\u7528TSC\u540c\u6b65\uff0c\u4e00\u822c\u90fd\u662f\u540c\u6b65\u7684\u3002<\/li><li>\u5728Intel CPU\u4e0b\u8fd8\u6709\u4e00\u4e2a\u6ce8\u91ca\u201cassume multi socket systems are not synchronized\u201d\uff0c\u5373\u5728\u591a\u5904\u7406\u5668\u7cfb\u7edf\u4e0a\uff0c\u4e0d\u540cCPU\uff08\u5904\u7406\u5668\u3001socket\u3001NUMA\u8282\u70b9\uff09\u4e4b\u95f4\u7684TSC\u662f\u4e0d\u540c\u6b65\u7684\u3002<\/li><\/ul>\n\n\n\n<p>\u770b\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u57fa\u672c\u4e0a\u53ef\u4ee5\u786e\u5b9a\u4e86\uff0c\u5373\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5982\u679c\u4f60\u7684cpuinfo\u91cc\u6709constant_tsc\u7684flag\uff0c\u90a3\u4e48\u65e0\u8bba\u5728\u540c\u4e00CPU\u4e0d\u540c\u6838\u5fc3\u4e4b\u95f4\uff0c\u8fd8\u662f\u5728\u4e0d\u540cCPU\u7684\u4e0d\u540c\u6838\u5fc3\u4e4b\u95f4\uff0cTSC\u90fd\u662f\u540c\u6b65\u7684\uff0c\u53ef\u4ee5\u968f\u4fbf\u7528<\/li><li>\u5982\u679c\u4f60\u7528\u7684\u662fIntel\u7684CPU\uff0c\u4f46\u662fcpuinfo\u91cc\u6ca1\u6709constant_tsc\u7684flag\uff0c\u90a3\u4e48\u5728\u540c\u4e00\u5904\u7406\u5668\u7684\u4e0d\u540c\u6838\u5fc3\u4e4b\u95f4\uff0cTSC\u4ecd\u7136\u662f\u540c\u6b65\u7684\uff0c\u4f46\u662f\u4e0d\u540cCPU\u7684\u4e0d\u540c\u6838\u5fc3\u4e4b\u95f4\u4e0d\u540c\u6b65\uff0c\u5c3d\u91cf\u4e0d\u8981\u7528<\/li><\/ul>\n\n\n\n<p>\u81f3\u6b64\uff0c\u3010<strong>\u57512<\/strong>\u3011\u4e5f\u57fa\u672c\u4e0a\u89e3\u51b3\u4e86\u3002<\/p>\n\n\n\n<p>\u5173\u4e8e\u3010<strong>\u57513<\/strong>\u3011\uff0c\u5373\u4e71\u5e8f\u6267\u884c\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528<strong>RDTSCP<\/strong>\u547d\u4ee4\u6765\u4ee3\u66ffRDTSC\uff0c\u524d\u8005\u5f00\u9500\u867d\u7136\u7565\u9ad8\uff0c\u4f46\u80dc\u5728\u7a33\u5b9a\u597d\u7528\u3002\u53e6\u5916\uff0c\u5982\u679c\u4e0d\u60f3\u7528\u8fd9\u4e2a\u6307\u4ee4\uff0c\u8fd8\u53ef\u4ee5\u7528memory barrier\u6280\u672f\uff08\u540e\u9762\u7684\u6587\u7ae0\u4e2d\u6211\u4eec\u5c06\u8be6\u7ec6\u89e3\u91ca\u8be5\u6280\u672f\uff09\u6216\u8005CPUID\u6307\u4ee4\u6765\u5b9e\u73b0\uff0c\u4e0d\u8fc7\u8fd9\u4e24\u8005\u6211\u90fd\u6ca1\u8bd5\uff0c\u636e\u8bf4\u5f00\u9500\u4e5f\u4e0d\u5c0f\uff0c\u8be6\u7ec6\u8d44\u6599\u53ef\u4ee5\u5c31\u53c2\u89c1\u53c2\u8003\u8d44\u6599\u4e2d\u7684wiki\u9875\u9762\u548cintel\u7684\u5b98\u65b9\u624b\u518c\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u53ef\u4ee5\u7528\u6765\u6d4b\u8bd5RDTSC\u548cRDTSCP\u6307\u4ee4\u7684\u6027\u80fd\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;unistd.h>\n#include &lt;stdlib.h> \n#include &lt;stdint.h>\n#include &lt;time.h>\n#include &lt;sys\/time.h>\n\n\/\/ gcc -o time_6 time_6.c\n\nuint64_t get_tsc()\n{\n    uint64_t a, d;\n    __asm__ volatile(\"rdtsc\" : \"=a\"(a), \"=d\"(d));\n    return (d &lt;&lt; 32) | a;\n}\n\nuint64_t get_tscp()\n{\n    uint64_t a, d;\n    __asm__ volatile(\"rdtscp\" : \"=a\"(a), \"=d\"(d));\n    return (d &lt;&lt; 32) | a;\n}\n\n#define LOOP_TIMES 1000000000\n\nint main(int argc, char **argv)\n{\n    uint64_t beg_tsc, end_tsc;\n    long loop;\n    long sum;\n\n    printf(\"-------------rdtsc-------------\\n\");\n    loop = LOOP_TIMES;\n    sum = 0;\n    while(loop--)\n    {\n        beg_tsc = get_tsc(); \n        end_tsc = get_tsc();\n        sum += (end_tsc - beg_tsc);\n    }\n    printf(\"AVG_CYCLE : %ld\\n\", sum \/ LOOP_TIMES);\n\n    sleep(1);\n\n    printf(\"-------------rdtscp-------------\\n\");\n    loop = LOOP_TIMES;\n    sum = 0;\n    while(loop--)\n    {\n        beg_tsc = get_tscp(); \n        end_tsc = get_tscp();\n        sum += (end_tsc - beg_tsc);\n    }\n    printf(\"AVG_CYCLE : %ld\\n\", sum \/ LOOP_TIMES);\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u6d4b\u8bd5\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"244\" src=\"http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/11\/image-36.png\" alt=\"\" class=\"wp-image-907\"\/><\/figure>\n\n\n\n<p>\u6211\u4e00\u5171\u8dd1\u4e86\u4e09\u6b21\uff0c\u6bcf\u6b21\u5dee\u522b\u90fd\u4e0d\u5927\uff0cRDTSCP\u6307\u4ee4\u6bd4RDTSC\u591a\u8017\u8d3910\u4e2a\u6307\u4ee4\u5468\u671f\u5de6\u53f3\uff0c\u6162\u4e0d\u52301\u500d\u3002\u5982\u679c\u4f60\u80fd\u63a5\u53d7\u8fd9\u70b9\u5dee\u522b\uff0c\u5efa\u8bae\u8fd8\u662f\u7528RDTSCP\u547d\u4ee4\u5427\u3002<\/p>\n\n\n\n<p>\u53e6\u5916\uff0cRDTSCP\u6307\u4ee4\u4e5f\u662f\u9700\u8981\u5e73\u53f0\u652f\u6301\u7684\uff0c\u662f\u5426\u652f\u6301\u53ef\u4ee5\u4f7f\u7528<strong>cat \/proc\/cpuinfo | grep rdtscp<\/strong>\u547d\u4ee4\u67e5\u770b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5.\u4f7f\u7528\u5efa\u8bae<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5982\u679c\u4f60\u7684cpuinfo\u91cc\u9762\u6ca1\u6709constant_tsc\u7684flag\uff0c\u5efa\u8bae\u8001\u8001\u5b9e\u5b9e\u7528clock_gettime\u5427\uff0c\u6216\u8005\u6362\u53f0\u652f\u6301constant_tsc\u7684\u673a\u5668<\/li><li>\u5982\u679c\u4f60\u7684cpuinfo\u91cc\u9762\u6709constant_tsc\u7684flag\uff0c\u90a3\u4e48\u5728\u540c\u4e00\u5904\u7406\u5668\u7684\u4e0d\u540c\u6838\u5fc3\u4e4b\u95f4\u53ef\u4ee5\u653e\u5fc3\u4f7f\u7528TSC\uff0c\u8de8\u5904\u7406\u5668\u7684\u4e0d\u540c\u6838\u4e4b\u95f4\uff0c\u5c3d\u91cf\u907f\u514d\u4f7f\u7528\uff0c\u53ef\u80fd\u4f1a\u6709\u672a\u77e5\u7684\u95ee\u9898<\/li><li>\u5982\u679c\u4e0d\u662f\u5bf9\u6027\u80fd\u6781\u5176\u654f\u611f\uff0c\u5c3d\u91cf\u4f7f\u7528RDTSCP\u4ee3\u66ffRDTSC\uff0c\u524d\u8005\u7565\u6162\uff0c\u4f46\u80fd\u907f\u514dCPU\u4e71\u5e8f\u6267\u884c\u95ee\u9898<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">6.\u5f85\u660e\u786e\u95ee\u9898<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>TSC\u662f\u771f\u5b9e\u7684\u5bc4\u5b58\u5668\uff0c\u8fd8\u662f\u4e0a\u5c42\u5c01\u88c5\u7684\u4e00\u4e2a\u865a\u62df\u7684\u6307\u4ee4<\/li><li>TSC\u7a76\u7adf\u662f\u4e00\u4e2a\u6838\u5fc3\u4e00\u4e2a\uff0c\u8fd8\u662f\u4e00\u4e2aCPU\u4e00\u4e2a\uff0c\u8fd8\u662f\u6574\u4e2a\u7cfb\u7edf\u4e00\u4e2a<\/li><li>RDTSCP\u7a76\u7adf\u662f\u5982\u4f55\u5b9e\u73b0\u7981\u6b62\u4e71\u5e8f\u6267\u884c\u7684\uff0c\u4f7f\u7528memory barrier\u548ccpuid\u6307\u4ee4\u5982\u4f55\u5b9e\u73b0\u540c\u6837\u7684\u529f\u80fd\uff0c\u5f00\u9500\u5982\u4f55<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">7.\u53c2\u8003\u8d44\u6599<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5927\u795e\u9648\u7855\u7684\u6587\u7ae0\uff1a<a href=\"https:\/\/blog.csdn.net\/Solstice\/article\/details\/5196544\">\u94fe\u63a5\u5728\u6b64<\/a><\/li><li>\u53e6\u4e00\u7bc7\u4e2d\u6587\u6587\u7ae0\uff1a<a href=\"https:\/\/www.cnblogs.com\/ralphjzhang\/archive\/2012\/01\/09\/2317463.html\">\u94fe\u63a5\u5728\u6b64<\/a><\/li><li>\u7ef4\u57fa\u767e\u79d1\u76f8\u5173\u8bcd\u6761\uff1a<a href=\"https:\/\/en.wikipedia.org\/wiki\/Time_Stamp_Counter\">\u94fe\u63a5\u5728\u6b64<\/a><\/li><li>Stack Overflow\u4e0a\u7684\u8ba8\u8bba\uff1a<a href=\"https:\/\/stackoverflow.com\/questions\/3388134\/rdtsc-accuracy-across-cpu-cores\">\u94fe\u63a5\u5728\u6b64<\/a><\/li><li>Intel\u5b98\u65b9\u624b\u518c\uff0c\u53c2\u8003 17.15 TIME-STAMP COUNTER\uff1a<a href=\"https:\/\/www.intel.com\/content\/dam\/www\/public\/us\/en\/documents\/manuals\/64-ia-32-architectures-software-developer-vol-3b-part-2-manual.pdf\">\u94fe\u63a5\u5728\u6b64<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1.\u524d\u8a00 \u524d\u51e0\u5929\u5199\u4e86\u4e00\u7bc7\u6587\u7ae0\uff08\u94fe\u63a5\u5728\u6b64\uff09\uff0c\u63a2\u7d22\u5404\u79cd\u53d6\u65f6\u95f4\u7684\u65b9\u5f0f\uff0c\u7ed3\u8bba\u662fTSC\u662f\u7cbe\u5ea6\u6700\u9ad8\u3001\u5f00\u9500\u6700\u5c0f\u7684\u65b9\u5f0f\uff0c\u4f46\u662f\u540c\u65f6\u4e5f\u58f0\u660e\u4e86\uff0c\u4f7f\u7528\u7684\u65f6\u5019\u53ef\u80fd\u4f1a\u78b0\u89c1\u5f88\u591a\u5751\u3002 \u4eca\u5929\u6211\u4eec&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/www.wangkaixuan.tech\/?p=901\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-901","post","type-post","status-publish","format-standard","hentry","category-05-01-"],"_links":{"self":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=901"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/901\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=901"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}