{"id":4367,"date":"2020-07-01T17:48:15","date_gmt":"2020-07-01T09:48:15","guid":{"rendered":"https:\/\/damogame.cn\/wordpress\/?p=4367"},"modified":"2020-07-01T17:48:15","modified_gmt":"2020-07-01T09:48:15","slug":"buddy-memory-allocation-%e4%bc%99%e4%bc%b4%e5%86%85%e5%ad%98%e5%88%86%e9%85%8d%e5%99%a8","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/4367","title":{"rendered":"Buddy memory allocation (\u4f19\u4f34\u5185\u5b58\u5206\u914d\u5668)"},"content":{"rendered":"<div id=\"entry-734\" class=\"entry\">\n<h3 class=\"entry-header\"><a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html\">\u539f\u6587\u5730\u5740<\/a><\/h3>\n<p>&nbsp;<\/p>\n<div class=\"entry-content\">\n<div class=\"entry-body\">\n<p>\u4eca\u5929\u5403\u665a\u996d\u7684\u65f6\u5019\u60f3\u5230\uff0c\u6211\u9700\u8981\u4e00\u4e2a\u5b9a\u5236\u7684\u5185\u5b58\u5206\u914d\u5668\u3002\u4e3b\u8981\u662f\u4e3a\u4e86\u89e3\u51b3\u00a0<a href=\"http:\/\/blog.codingnow.com\/2011\/12\/dev_note_6.html\">\u5171\u4eab\u5185\u5b58<\/a>\u00a0\u4e2d\u7684\u5b57\u7b26\u4e32\u6c60\u7684\u7ba1\u7406\u3002<\/p>\n<p>\u8fd9\u4e2a\u5185\u5b58\u5206\u914d\u5668\u9700\u8981\u662f\u975e\u5165\u4fb5\u5f0f\u7684\uff0c\u5373\u4e0d\u5728\u8981\u5206\u914d\u7684\u5185\u5b58\u5757\u4e2d\u5199 cookie \u3002<\/p>\n<p>\u800c\u6211\u7684\u9700\u6c42\u4e2d\uff0c\u9700\u8981\u88ab\u7ba1\u7406\u7684\u5185\u5b58\u5757\u90fd\u662f\u5f88\u89c4\u5219\u7684\uff0c\u6210 2 \u7684\u6574\u6570\u6b21\u5e42\u7684\u957f\u5ea6\u3002<a href=\"http:\/\/en.wikipedia.org\/wiki\/Buddy_memory_allocation\">buddy memory allocation<\/a>\u00a0\u521a\u597d\u9002\u7528\u3002<\/p>\n<p>\u7b97\u6cd5\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u6bcf\u6b21\u628a\u4e00\u4e2a\u6b63\u5185\u5b58\u5757\u5bf9\u534a\u5207\u5206\uff0c\u4e00\u76f4\u5207\u5230\u9700\u8981\u7684\u5927\u5c0f\u5206\u914d\u51fa\u53bb\u3002\u56de\u6536\u7684\u65f6\u5019\uff0c\u5982\u679c\u8ddf\u5b83\u914d\u5bf9\u7684\u5757\u4e5f\u662f\u672a\u88ab\u4f7f\u7528\u7684\uff0c\u5c31\u5408\u5e76\u6210\u4e00\u4e2a\u5927\u7684\u5757\u3002\u6807\u51c6\u7b97\u6cd5\u4e0b\uff0c\u5206\u914d\u548c\u91ca\u653e\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u90fd\u662f O(log N) \uff0cN \u4e0d\u4f1a\u7279\u522b\u5927\u3002\u7b97\u6cd5\u7684\u4f18\u70b9\u662f\u788e\u7247\u7387\u5f88\u5c0f\u3002\u800c\u4e14\u5f88\u5bb9\u6613\u505a\u6210\u975e\u5165\u4fb5\u5f0f\u7684\uff0c\u4e0d\u7528\u5728\u88ab\u7ba1\u7406\u7684\u5185\u5b58\u4e0a\u4fdd\u5b58 cookie \u3002\u53ea\u9700\u8981\u989d\u5916\u5f00\u8f9f\u4e00\u4e2a\u4e8c\u53c9\u6811\u8bb0\u5f55\u5185\u5b58\u4f7f\u7528\u72b6\u6001\u5373\u53ef\u3002<\/p>\n<p>\u6211\u5403\u5b8c\u996d\u7b80\u5355 google \u4e86\u4e00\u4e0b\uff0c\u6ca1\u6709\u7acb\u523b\u627e\u5230\u6ee1\u8db3\u6211\u8981\u6c42\u7684\u73b0\u6210\u4ee3\u7801\u3002\u5fc3\u91cc\u4f30\u7b97\u4e86\u4e00\u4e0b\uff0cC \u4ee3\u7801\u91cf\u5e94\u8be5\u5728 200 \u884c\u4ee5\u4e0b\uff0c\u6211\u5927\u6982\u53ef\u4ee5\u5728 1 \u5c0f\u65f6\u5185\u5199\u5b8c\u3002\u6240\u4ee5\u5c31\u6beb\u4e0d\u72b9\u8c6b\u7684\u5b9e\u73b0\u4e86\u4e00\u4efd\u3002<\/p>\n<p>\u7136\u540e\uff0c\u81ea\u7136\u662f\u5f00\u6e90\u4e86\u3002\u6709\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5<a href=\"https:\/\/github.com\/cloudwu\/buddy\">\u53bb github \u62ff\u4e00\u4efd<\/a>\u3002\u8fd9\u6837\u5c31\u7701\u5f97\u5230\u518d\u9700\u8981\u65f6\u518d\u9020\u8f6e\u5b50\u4e86\u3002\u563f\u563f\u3002<\/p>\n<\/div>\n<div id=\"more\" class=\"entry-more\">\n<p>btw, \u5f53\u7136\u8fd9\u5757\u4ee3\u7801\u6709\u8bb8\u591a\u503c\u5f97\u4f18\u5316\u7684\u5730\u65b9\uff0c\u6bd4\u5982\u53ef\u4ee5\u628a\u91cc\u9762\u7684\u9012\u5f52\u4f18\u5316\u6210\u5faa\u73af\u56de\u6eaf\u3002\u8fd9\u4e2a\u7b97\u6cd5\u6211\u8bfb\u521d\u4e2d\u65f6\u7ecf\u5e38\u5199\u3002\u56e0\u4e3a\u521d\u4e00\u90a3\u4e2a\u65f6\u5019\u53c2\u52a0\u4fe1\u606f\u5b66\u5965\u8d5b\u65f6\u7528\u7684 basic \u4e0d\u652f\u6301\u5c40\u90e8\u53d8\u91cf\uff0c\u5168\u90e8\u53d8\u91cf\u90fd\u662f\u5168\u5c40\u7684\uff0c\u5f88\u96be\u5b9e\u73b0\u9012\u5f52\u3002\u6240\u4ee5\u65e9\u671f\u6211\u90fd\u4e0d\u7528\u9012\u5f52\u904d\u5386\u4e8c\u53c9\u6811\u7684\uff0c\u611f\u89c9\u5199\u8d77\u6765\u597d\u9ebb\u70e6\u3002<\/p>\n<p>\u4e0d\u8fc7\u5faa\u73af\u56de\u6eaf\u904d\u5386\u6811\u5e94\u8be5\u662f\u6bd4\u9012\u5f52\u5feb\u4e0d\u5c11\u7684\uff0c\u56e0\u4e3a\u51cf\u5c11\u4e86\u8bb8\u591a\u4e0d\u5fc5\u8981\u7684\u73af\u5883\u53d8\u91cf\u538b\u6808\uff0c\u5bf9\u4e0d\u652f\u6301 closure \u7684 C \u8bed\u8a00\u5c24\u5176\u662f\u3002<\/p>\n<p>\u8fd9\u4e2a\u5e93\u7528\u8d77\u6765\u5f88\u7b80\u5355\u3002\u5b83\u5e76\u4e0d\u5b9e\u9645\u7ba1\u7406\u5185\u5b58\uff08\u5b83\u4e0d\u4fb5\u5165\u88ab\u7ba1\u7406\u7684\u5185\u5b58\uff09\u3002\u4f60\u53ef\u4ee5\u8bbe\u60f3\u4f60\u53e6\u5916\u6709\u4e00\u5927\u5757\u5185\u5b58\u662f\u7531\u8bb8\u591a\u6700\u5c0f\u5355\u4f4d\u5757\u5408\u8d77\u6765\u7684\u3002\u4f60\u53ef\u4ee5\u5047\u8bbe\u6700\u5c0f\u5355\u4f4d\u662f 1K \u3002\u90a3\u4e48\u7528\u00a0<code>buddy_new(10)<\/code>\u00a0\u5c31\u53ef\u4ee5\u5e2e\u4f60\u7ba1\u7406 1024K \u5185\u5b58\u3002<\/p>\n<p><code>buddy_alloc<\/code>\u00a0\u53ef\u4ee5\u8bf7\u6c42\u82e5\u5e72\u4e2a\u6700\u5c0f\u5355\u4f4d\u5757\uff0c\u8fd4\u56de\u4e00\u4e2a\u5e8f\u53f7\u3002\u7136\u540e\u7528\u6237\u53ef\u4ee5\u81ea\u5df1\u53bb\u5927\u5185\u5b58\u4e0a\u7d22\u5f15\u51fa\u6765\u7528\u3002\u7528\u5b8c\u8c03\u7528\u00a0<code>buddy_free<\/code>\u00a0\u5f52\u8fd8\u5373\u53ef\u3002<\/p>\n<p>\u4e3a\u4e86\u8c03\u8bd5\u65b9\u4fbf\uff0c\u6211\u8fd8\u63d0\u4f9b\u4e86\u00a0<code>buddy_dump<\/code>\u00a0\u6253\u5370\u4e8c\u53c9\u6811\u7684\u7ec6\u8282\uff0c\u53ef\u4ee5\u76f4\u89c2\u7684\u770b\u51fa\u90a3\u4e9b\u5185\u5b58\u533a\u57df\u672a\u88ab\u4f7f\u7528\uff0c\u54ea\u4e9b\u5df2\u7ecf\u88ab\u5360\u7528\u3002<\/p>\n<p>ps. \u679c\u7136\uff0c\u5199\u8fd9\u7bc7 blog \u82b1\u6389\u7684\u65f6\u95f4\u6bd4\u5b8c\u6210\u8fd9\u4e9b\u4ee3\u7801\u65f6\u95f4\u66f4\u957f\u3002\u4ee3\u7801\u4e5f\u5982\u6211\u6240\u6599\u7684\u6ca1\u6709\u8d85\u8fc7 200 \u884c\u3002\u770b\u770b\uff0c\u628a\u4e1c\u897f\u63cf\u8ff0\u6e05\u695a\u5c31\u662f\u6bd4\u5b9e\u73b0\u4e00\u4e2a\u4e1c\u897f\u8981\u82b1\u66f4\u957f\u7684\u65f6\u95f4\uff0c\u8fd9\u5c31\u662f\u9879\u76ee\u4eba\u591a\u53cd\u800c\u505a\u7684\u6162\u7684\u539f\u56e0\u4e4b\u4e00\u5427\u3002<\/p>\n<hr \/>\n<p>12 \u6708 21 \u65e5:<\/p>\n<p>\u611f\u89c9\u7528\u4e86\u9012\u5f52\u5f88\u4e0d\u723d, \u6240\u4ee5\u91cd\u5199\u4e86\u5b9e\u73b0, \u6539\u7528\u5b8c\u5168\u4e8c\u53c9\u6811\u50a8\u5b58, \u53bb\u6389\u4e86\u9012\u5f52. \u5e76\u4e14(\u4e5f\u662f\u4e3b\u8981\u539f\u56e0) \u51cf\u5c11\u4e86\u5185\u5b58\u5360\u7528.<\/p>\n<p>\u5982\u679c\u9700\u8981\u4f18\u5316\u7684\u8bdd, \u5e94\u8be5\u52a0\u4e00\u7ec4 free list , \u8fd9\u4e2a\u518d\u8bf4\u3002\u6211\u81ea\u5df1\u7684\u9700\u6c42\u4e2d\uff0c\u65f6\u95f4\u6027\u80fd\u5e76\u4e0d\u592a\u654f\u611f\u3002<\/p>\n<hr \/>\n<p>12 \u6708 25 \u65e5: \u697c\u4e0b\u6709 wuwenbin \u63d0\u5230\u53ef\u4ee5\u5728\u8282\u70b9\u4e2d\u4fdd\u5b58\u6700\u5927\u8fde\u7eed\u7a7a\u95f2\u533a\u57df\u6765\u4f18\u5316\u5206\u914d\u8fc7\u7a0b. \u8fd9\u6837\u4ee3\u7801\u66f4\u77ed\u5c0f, \u901f\u5ea6\u4e5f\u53ef\u4ee5\u5feb\u4e00\u70b9. \u552f\u4e00\u7684\u7f3a\u61be\u662f\u5185\u5b58\u7565\u5fae\u6d88\u8017\u7684\u591a\u4e00\u70b9\u70b9. \u5b9e\u73b0\u5728\u00a0<a href=\"https:\/\/github.com\/wuwenbin\/buddy2\">https:\/\/github.com\/wuwenbin\/buddy2<\/a><\/p>\n<\/div>\n<\/div>\n<p class=\"entry-footer\"><span class=\"post-footers\">\u4e91\u98ce \u63d0\u4ea4\u4e8e December 20, 2011 09:38 PM<\/span>\u00a0<span class=\"separator\">|<\/span>\u00a0<a class=\"permalink\" href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html\">\u56fa\u5b9a\u94fe\u63a5<\/a><\/p>\n<\/div>\n<div id=\"comments\" class=\"comments\">\n<div class=\"comments-content\">\n<h3 class=\"comments-header\">COMMENTS<\/h3>\n<p><a id=\"c043921\"><\/a><\/p>\n<div id=\"comment-43921\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u5982\u679c\u4f7f\u7528\u6570\u7ec4\u800c\u4e0d\u662f\u94fe\u8868\u5b9e\u73b0\uff0c\u90a3\u4e48\u6709\u4e2a\u9650\u5236\u5c31\u662f\u5408\u5e76\u7b56\u7565\u5fc5\u987b\u662f\u76f8\u90bb\u7684\u5143\u7d20\u4e4b\u95f4\uff0c\u8fd9\u4ecd\u65e7\u4f1a\u5bfc\u81f4\u5916\u90e8\u788e\u7247\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: Leo | (35)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-43921\">May 4, 2013 12:24 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c043809\"><\/a><\/p>\n<div id=\"comment-43809\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u8fd9\u91cc\u6709\u4e00\u4e2a\u65e0\u5206\u652f\u7684\u5b9e\u73b0<br \/>\nstatic inline uint32_t<br \/>\nnext_pow_of_2(uint32_t x) {<br \/>\nx -= 1;<br \/>\nx |= x&gt;&gt;1;<br \/>\nx |= x&gt;&gt;2;<br \/>\nx |= x&gt;&gt;4;<br \/>\nx |= x&gt;&gt;8;<br \/>\nx |= x&gt;&gt;16;<br \/>\nreturn x+1;<br \/>\n}<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: hhh2000 | (34)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-43809\">March 23, 2013 03:56 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c043737\"><\/a><\/p>\n<div id=\"comment-43737\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u6211\u5df2\u7ecf\u5b9e\u73b0\u4e861\u5b57\u8282\u7248\u672c\u3002\u771f\u662f\u592a\u7cbe\u5999\u4e86\uff0c\u6559\u79d1\u4e66\u4e00\u6837\uff0c@wuwenbin\u600e\u4e48\u60f3\u5230\u7684\u54e6\uff01<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/www.cnblogs.com\/cbscan\/\" rel=\"nofollow\">Scan<\/a>\u00a0| (33)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-43737\">February 24, 2013 11:53 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c043736\"><\/a><\/p>\n<div id=\"comment-43736\" class=\"comment\">\n<div class=\"comment-content\">\n<p>@wuwenbin<br \/>\n\u4ed6\u7684\u5b9e\u73b0\u91cc\u9762\uff0c\u5982\u679c\u628alongest\u6539\u4e3a\u5b58\u50a8log2\uff0c\u5219\u53ea\u9700\u8981\u4e00\u4e2a\u5b57\u8282\u5c31\u53ef\u4ee5\u4e86\uff0c\u5185\u5b58\u5360\u7528\u4e0a\u548c\u4e91\u98ce\u4f60\u7684\u65b9\u6848\u662f\u4e00\u6837\u7684\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/www.cnblogs.com\/cbscan\/\" rel=\"nofollow\">Scan<\/a>\u00a0| (32)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-43736\">February 24, 2013 11:51 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042714\"><\/a><\/p>\n<div id=\"comment-42714\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u975e\u5e38\u4e0d\u9002\u5e94\u7ed3\u6784\u4f53\u5411\u540e\u6269\u5c55\u6570\u636e\u7684\u505a\u6cd5.<br \/>\nstruct buddy {<br \/>\nint level;<br \/>\nuint8_t tree[1];<br \/>\n};<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: pthread_t | (31)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42714\">May 18, 2012 04:57 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042715\"><\/a><\/p>\n<div id=\"comment-42715\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u975e\u5e38\u4e0d\u9002\u5e94\u7ed3\u6784\u4f53\u5411\u540e\u6269\u5c55\u6570\u636e\u7684\u505a\u6cd5.<br \/>\nstruct buddy {<br \/>\nint level;<br \/>\nuint8_t tree[1];<br \/>\n};<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: pthread_t | (30)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42715\">May 18, 2012 04:57 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042449\"><\/a><\/p>\n<div id=\"comment-42449\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u98ce\u4e91\uff0c\u80fd\u4e0d\u80fd\u5728\u4ee3\u7801\u4e2d\u7ed9\u70b9\u6ce8\u91ca\u554a? \u770b\u5f97\u5403\u529b\u3002\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: frankiejun | (29)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42449\">March 6, 2012 09:30 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042144\"><\/a><\/p>\n<div id=\"comment-42144\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u54c8\u54c8\uff0c~\u62ff\u53bb\u5b66\u4e60\u4e0b\u4e86\uff0c\u611f\u8c22<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: ash | (28)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42144\">January 4, 2012 10:41 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042137\"><\/a><\/p>\n<div id=\"comment-42137\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u4f19\u4f34\u7cfb\u7edf linux kernel\u7684\u5185\u5b58\u7ba1\u7406\u7b97\u6cd5\u5c31\u662f\u4f19\u4f34\u7cfb\u7edf<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: \u738b\u6770 | (27)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42137\">December 31, 2011 03:34 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042125\"><\/a><\/p>\n<div id=\"comment-42125\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u633a\u4e0d\u9519\u7684\uff01<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/www.kaopuhao.com\/\" rel=\"nofollow\">\u9760\u8c31\u53f7<\/a>\u00a0| (26)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42125\">December 28, 2011 01:07 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042124\"><\/a><\/p>\n<div id=\"comment-42124\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u4e3a\u4f55\u4e0d\u7528\u300a\u611f\u609f\u300b\u91cc\u7684smallobject_allocator \ud83d\ude42<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: breaker | (25)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42124\">December 27, 2011 01:54 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042123\"><\/a><\/p>\n<div id=\"comment-42123\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u5355\u680f\u4e3b\u9898\u8fd8\u662f\u86ee\u597d\u770b\u7684\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/www.cnhawkhost.com\/\" rel=\"nofollow\">hawkhost<\/a>\u00a0| (24)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42123\">December 27, 2011 12:38 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042122\"><\/a><\/p>\n<div id=\"comment-42122\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u8fd9\u4e2a\u4e1c\u897f\u5728acm\u4e2d\u5c31\u53eb\u7ebf\u6bb5\u6811<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: Anonymous | (23)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42122\">December 27, 2011 11:33 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042117\"><\/a><\/p>\n<div id=\"comment-42117\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u6811\u5f62slab\u5e94\u8be5\u6bd4buddy\u66f4\u597d\u5427<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: skywind | (22)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42117\">December 26, 2011 03:13 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042116\"><\/a><\/p>\n<div id=\"comment-42116\" class=\"comment\">\n<div class=\"comment-content\">\n<p>@wuwenbin<\/p>\n<p>\u8fd9\u6837\u662f\u597d\u4e00\u4e9b. \u6211\u52a0\u5230\u4e3b\u5e16\u91cc\u53bb.<\/p>\n<p>btw, \u524d\u9762\u56de\u590d\u662f\u7b14\u8bef. \u5206\u914d\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u662f log n \u4e0d\u662f n log n<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: Cloud | (21)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42116\">December 25, 2011 10:13 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042115\"><\/a><\/p>\n<div id=\"comment-42115\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u8fd8\u6709\u4e00\u4e2a\u7b80\u5355\u7684\u4f18\u5316\u529e\u6cd5\uff1a<br \/>\n\u4e0d\u5728\u8282\u70b9\u4e0a\u5b58\u50a8\u6807\u8bb0\uff0c\u6539\u4e3a\u5b58\u50a8\u8fd9\u4e2a\u8282\u70b9\u8868\u793a\u7684\u53ef\u7528\u7684\u8fde\u7eed\u5185\u5b58\u4e2d\u6700\u957f\u7684\u90a3\u4e00\u6bb5\u5185\u5b58\u7684\u957f\u5ea6\u3002<br \/>\n\u7ef4\u62a4\u8fd9\u4e2a\u57df\u5f88\u7b80\u5355\uff0c\u6700\u7ec8\u7684\u5b9e\u73b0\u4ee3\u7801\u6bd4\u4e91\u98ce\u7684\u7248\u672c\u77ed\u7684\u591a\uff0c\u6211\u7684\u5b9e\u73b0\u4ec5\u6709131 sloc\u3002<br \/>\n\u5728\u7a7a\u95f4\u6d88\u8017\u4e0a\uff0c\u53ef\u80fd\u4f1a\u6bd4\u4e91\u98ce\u7684\u5b9e\u73b0\u8017\u7528\u66f4\u591a\u7684\u5185\u5b58\u3002\u56e0\u4e3a\u8981\u5728\u6bcf\u4e2a\u8282\u70b9\u4e0a\u5b58\u50a8\u957f\u5ea6\uff0c\u4e0d\u50cf\u6807\u8bb0\u90a3\u6837\u51e0\u4e2abit\u5c31\u591f\u7528\u3002\u6211\u7684\u5b9e\u73b0\u7248\u672c\u6bcf\u4e2a\u8282\u70b9\u67094\u4e2a\u5b57\u8282\uff0c\u8017\u7528\u7a7a\u95f4\u662f\u4e91\u98ce\u7248\u672c\u76844\u500d\u3002\u5982\u679c\u4e0d\u9700\u8981\u5212\u5206\u592a\u591a\u5185\u5b58\u5757\u7684\u8bdd\uff0c\u4e5f\u53ef\u4ee5\u51cf\u5c11\u7a7a\u95f4\u5360\u7528\u3002<br \/>\n\u5728\u65f6\u95f4\u6548\u7387\u4e0a\uff0c\u5e94\u8be5\u4f1a\u6bd4\u4e91\u98ce\u7684\u5b9e\u73b0\u5feb\u7684\u591a\uff0c\u540c\u662fnlogn\u7684\uff0c\u4f46\u662f\u4ee3\u7801\u5c11\uff0c\u5224\u65ad\u7684\u5206\u652f\u4e5f\u5c11\uff0c\u6bcf\u4e00\u6b21\u8bbf\u95ee\u67d0\u4e2a\u8282\u70b9\u53ef\u4ee5\u7acb\u523b\u51b3\u5b9a\u5206\u914d\u5de6\u8282\u70b9\u8fd8\u662f\u53f3\u8282\u70b9\uff0c\u4e0d\u9700\u8981\u56de\u6eaf\u3002<br \/>\n\u6211\u7684\u5b9e\u73b0\u4ee3\u7801\u5728\uff1ahttps:\/\/github.com\/wuwenbin\/buddy2<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: wuwenbin | (20)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42115\">December 25, 2011 03:58 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042109\"><\/a><\/p>\n<div id=\"comment-42109\" class=\"comment\">\n<div class=\"comment-content\">\n<p>google\u6709\u4ec0\u4e48\u597d\uff0c\u4e00\u4f1a\u513f\u65e0\u6cd5\u641c\u7d22\uff0c\u4e00\u4f1a\u513f\u53c8\u53ef\u4ee5\uff0c\u771f\u7684\u662f\u6c14\u6b7b\u4eba\u3002\u4e0d\u77e5\u4ed6\u4eec\u516c\u53f8\u5728\u641e\u4ec0\u4e48\u9b3c\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: asfrewa | (19)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42109\">December 22, 2011 09:39 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042108\"><\/a><\/p>\n<div id=\"comment-42108\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u98ce\u4e91\u539f\u6765\u5982\u6b64\u5440\u5443<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/www.daidai.co\/\" rel=\"nofollow\">QQ\u5206\u7ec4<\/a>\u00a0| (18)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42108\">December 22, 2011 08:49 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042103\"><\/a><\/p>\n<div id=\"comment-42103\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u60f3\u60f3\u662f\u4e3e\u624b\u4e4b\u52b3\u7684\u4f18\u5316,\u5c31\u4e0d\u5077\u61d2\u4e86. \u52a0\u4e0a. \u73b0\u5728\u4e0d\u4f1a\u9000\u5316\u5230 O(n) \u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e86.<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: Cloud | (17)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42103\">December 22, 2011 01:39 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042102\"><\/a><\/p>\n<div id=\"comment-42102\" class=\"comment\">\n<div class=\"comment-content\">\n<p>@Tiger Soldier<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u6807\u8bb0\u628a\u6574\u4e2a\u5b50\u6811\u6807\u8bb0\u8d77\u6765(\u52a0\u4e00\u4e2a\u989c\u8272\u6807\u8bb0), \u51cf\u5c11\u65f6\u95f4\u590d\u6742\u5ea6. \u8fd9\u662f\u4e2a\u4f18\u5316, \u6211\u6ca1\u6709\u505a. \u6709\u7a7a\u53ef\u4ee5\u52a0\u4e0a, \u628a\u590d\u6742\u5ea6\u51cf\u5230 O(logN) \u5de6\u53f3.<\/p>\n<p>\u53e6\u5916\u53ef\u4ee5\u628a\u95f2\u7f6e\u7a7a\u95f4\u4e32\u8d77\u6765, \u52a0\u5feb\u5206\u914d.<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: Cloud | (16)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42102\">December 22, 2011 01:22 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042101\"><\/a><\/p>\n<div id=\"comment-42101\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u5206\u914d\u7684\u590d\u6742\u5ea6\u662fO(logN)\u7684\u4e48\uff1f\u770b\u4e86\u4e00\u4e0b\u4ee3\u7801\uff0c\u611f\u89c9\u5728\u6700\u574f\u60c5\u51b5\u4e0b\uff08\u6240\u6709\u7533\u8bf7\u90fd\u662f\u8bf7\u6c42\u6700\u5c0f\u5355\u5143\uff0c\u4e5f\u5c31\u662f\u6240\u6709\u53f6\u5b50\u90fd\u88ab\u6807\u8bb0\u4e3aUSED\uff0c\u5206\u914d\u4e00\u4e2a\u6700\u5c0f\u5355\u5143\u9700\u8981\u904d\u5386\u6574\u68f5\u6811\uff0c\u590d\u6742\u5ea6\u662fO(N)\u7684\u3002<\/p>\n<p>\u5173\u952e\u5728\u4e8e\u53ea\u6709UNUSED\u662f\u88ab\u5408\u5e76\u7684\uff0c\u800cUSED\u6ca1\u6709\u88ab\u5408\u5e76<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/tigersoldier.is-programmer.com\/\" rel=\"nofollow\">Tiger Soldier<\/a>\u00a0| (15)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42101\">December 21, 2011 09:01 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042099\"><\/a><\/p>\n<div id=\"comment-42099\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u5206\u4eab,\u5f00\u6e90\u603b\u503c\u5f97\u8d5e\u8d4f\uff0c\u8ba4\u771f\u505a\u4e8b\u603b\u662f\u6709\u610f\u4e49<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: lichking | (14)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42099\">December 21, 2011 07:02 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042098\"><\/a><\/p>\n<div id=\"comment-42098\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u8fd9\u53eb\u53d1\u660e\u4e48\uff1f\u8fd9\u53eb\u5b9e\u73b0\u3002<\/p>\n<p>\u51e0\u884c\u4ee3\u7801\u800c\u5df2\uff0c\u6bd4\u5199\u4e2a hello world \u591a\u4e0d\u4e86\u591a\u5c11\u65f6\u95f4\uff0c\u8fd8\u6709\u6109\u60a6\u611f\u3002\u6bd4 google \u4e00\u4e2a\u522b\u4eba\u7684\u5b9e\u73b0\u8981\u4fbf\u6377\u3002\u53ea\u662f\u5199 blog \uff0c\u548c\u89e3\u91ca\u8fd9\u4e0d\u662f\u53d1\u660e\u8f6e\u5b50\u82b1\u7684\u65f6\u95f4\u6bd4\u8f83\u591a\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: Cloud | (13)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42098\">December 21, 2011 06:57 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042097\"><\/a><\/p>\n<div id=\"comment-42097\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u53c8\u91cd\u65b0\u53d1\u660e\u4e86\u4e00\u6b21buddy<\/p>\n<p>\u90a3\u4e0b\u4e00\u4e2a\u8f6e\u5b50\u5e94\u8be5\u662fslab allocator\u4e86\u5427\uff1f<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: nothing@null.com | (12)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42097\">December 21, 2011 06:05 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042096\"><\/a><\/p>\n<div id=\"comment-42096\" class=\"comment\">\n<div class=\"comment-content\">\n<p>linux kernel\u5e95\u5c42\u5c31\u662f\u8fd9\u4e48\u7ba1\u7406\u5185\u5b58\u5206\u914d\u7684\u5427\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: luguo1 | (11)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42096\">December 21, 2011 03:27 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042095\"><\/a><\/p>\n<div id=\"comment-42095\" class=\"comment\">\n<div class=\"comment-content\">\n<p>Android dynamic linker\u91cc\u9762\u6709\u4e2a\u5b9e\u73b0\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/www.wanglianghome.org\/\" rel=\"nofollow\">netcasper<\/a>\u00a0| (10)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42095\">December 21, 2011 02:22 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042094\"><\/a><\/p>\n<div id=\"comment-42094\" class=\"comment\">\n<div class=\"comment-content\">\n<p>@irachex<\/p>\n<p>\u4e5f\u662f, \u5199\u7684\u592a\u5306\u5fd9.<\/p>\n<p>\u5176\u5b9e\u76f4\u63a5\u50a8\u5b58\u4e3a\u5b8c\u5168\u4e8c\u53c9\u6811\u5c31\u7b80\u5355\u4e86, \u6709\u7a7a\u6539\u6539.<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: Cloud | (9)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42094\">December 21, 2011 12:13 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042093\"><\/a><\/p>\n<div id=\"comment-42093\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u548c\u7ebf\u6bb5\u6811\u9664\u4e86\u957f\u5f97\u50cf\u6709\u4e2a\u6bdb\u5173\u7cfb\u554a<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: lichking | (8)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42093\">December 21, 2011 11:13 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042092\"><\/a><\/p>\n<div id=\"comment-42092\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u7684\u786e\u662f\u7ebf\u6bb5\u6811\u3002\u5176\u5b9e\u8fd9\u4e2a\u975e\u9012\u5f52\u5e94\u8be5\u6bd4\u8f83\u597d\u5b9e\u73b0\u5427\uff0c\u7528node\u8868\u793a\u8282\u70b9\u7f16\u53f7\uff0c\u90a3\u4e48node*2\u548cnode*2+1\u8868\u793a\u5b83\u7684\u5de6\u53f3\u5b69\u5b50<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/irachex.com\/\" rel=\"nofollow\">irachex<\/a>\u00a0| (7)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42092\">December 21, 2011 09:48 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042091\"><\/a><\/p>\n<div id=\"comment-42091\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u611f\u8c22\u5206\u4eab<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: jokester | (6)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42091\">December 21, 2011 09:18 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042090\"><\/a><\/p>\n<div id=\"comment-42090\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u6ca1\u770b\u5230License\u554a\uff0c\u662f\u516c\u6709\u9886\u57df\u5417\uff1f<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/www.ac.net.blog.163.com\/\" rel=\"nofollow\">Atry<\/a>\u00a0| (5)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42090\">December 21, 2011 02:02 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042089\"><\/a><\/p>\n<div id=\"comment-42089\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u543c\u543c\uff0c\u8fd9\u4e0d\u5c31\u662f\u4f20\u8bf4\u4e2d\u7684\u7ebf\u6bb5\u6811\u5417\uff1f\u6211\u4eec\u8fd9\u91cc\u7684\u8001\u5e08\u90fd\u89c9\u5f97\u5965\u8d5b\u5c31\u662f\u667a\u529b\u7ade\u8d5b\uff0c\u6211\u8868\u793a\u5f88\u65e0\u8bed\u3002<br \/>\nPS\uff1a\u524d\u6392\u524d\u6392\u3002<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: ditsing | (4)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42089\">December 21, 2011 01:00 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042088\"><\/a><\/p>\n<div id=\"comment-42088\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u539f\u6765\u4e91\u98ce\u4e5f\u662f\u53c2\u52a0\u8fc7\u5965\u8d5b\u7684&#8230;\u554a\u54c8\u54c8<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by:\u00a0<a href=\"http:\/\/innocentim.info\/\" rel=\"nofollow\">INNOCENT<\/a>\u00a0| (3)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42088\">December 21, 2011 12:25 AM<\/a><\/p>\n<\/div>\n<p><a id=\"c042087\"><\/a><\/p>\n<div id=\"comment-42087\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u54c7, \u6211\u4e5f\u5199\u8fc7\u5728\u5171\u4eab\u5185\u5b58\u91ccbuddy allocator<\/p>\n<\/div>\n<p class=\"comment-footer\">Posted by: gebenxiang | (2)\u00a0<a href=\"https:\/\/blog.codingnow.com\/2011\/12\/buddy_memory_allocation.html#comment-42087\">December 20, 2011 11:09 PM<\/a><\/p>\n<\/div>\n<p><a id=\"c042086\"><\/a><\/p>\n<div id=\"comment-42086\" class=\"comment\">\n<div class=\"comment-content\">\n<p>\u8fd9\u5c31\u662f\u5f88\u591a\u4eba\u4e0d\u613f\u610f\u5199\u6587\u6863\u7684\u539f\u56e0\u5427\uff0c\u54c8\u54c8\u3002 \/\/ \u6c99\u53d1<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u5730\u5740 &nbsp; \u4eca\u5929\u5403\u665a\u996d\u7684\u65f6\u5019<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[119],"class_list":["post-4367","post","type-post","status-publish","format-standard","hentry","tag-03-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/4367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=4367"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/4367\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=4367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=4367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=4367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}