{"id":5006,"date":"2022-01-26T12:36:19","date_gmt":"2022-01-26T03:36:19","guid":{"rendered":"https:\/\/now0930.pe.kr\/wordpress\/?p=5006"},"modified":"2022-01-26T12:37:19","modified_gmt":"2022-01-26T03:37:19","slug":"linux-cache-memory","status":"publish","type":"post","link":"https:\/\/now0930.pe.kr\/wordpress\/linux-cache-memory\/","title":{"rendered":"linux cache memory"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">cache memroy \uc2e4\uc2b5<\/h3>\n\n\n\n<p>linux device driver, 8\uc7a5\uc744 \uc2e4\uc2b5 \ud588\ub2e4. \ucef4\ud30c\uc77c \ud558\uc5ec \uc2e4\ud589\ud558\uae30 \uc804\uc5d0\ub294 \uc5b4\ub5bb\uac8c \ub3cc\uc544\uac00\ub294\uc9c0 \uc798 \uc54c \uc218 \uc5c6\ub2e4. <a href=\"https:\/\/github.com\/starpos\/scull\">scullc<\/a>\uc744 \ubcf4\uace0 \ub530\ub77c\ud558\ub824 \ud588\uc73c\ub098 \uc798 \ubaa8\ub974\uaca0\ub2e4. \uba54\ubaa8\ub9ac\ub97c cache\ub85c \uc120\uc5b8\ud558\uace0 \uc77c\ubc18 \uba54\ubaa8\ub9ac\ub97c \uc4f0\ub4ef\uc774 \ud558\uba74 \ub41c\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include&lt;linux\/kernel.h>\n#include&lt;linux\/init.h>\n#include&lt;linux\/module.h>\n#include &lt;linux\/slab.h>\n\n#define scullc_quantum 16\n\n\/* declare one cache pointer: use it for all devices *\/\n\/* kmem_cache_t \uac00 kmem_cache\ub85c \ubcc0\uacbd\ub428*\/\nstruct kmem_cache *scullc_cache;\n\nstatic const char test[scullc_quantum]=\"123456789abcde\";\nstatic char* data;\nstatic int __init hello_world_init(void) \/* Constructor *\/\n{\n\tint i;\n\tprintk(KERN_INFO \"hello, cache memory\\n\");\n\t\/* memory \ud560\ub2f9*\/\n\tscullc_cache = kmem_cache_create(\"scullc\", scullc_quantum*sizeof(char),\n\t\t\t0, SLAB_HWCACHE_ALIGN, NULL); \/* no ctor *\/\n\n\tif (!scullc_cache) {\n\t\tprintk(KERN_ERR \"no memory. out.\\n\");\n\t\treturn -ENOMEM;\n\n\t}\n\t\/* allocate*\/\n\tdata = kmem_cache_alloc(scullc_cache, GFP_KERNEL);\n\tfor (i=0;i&lt;scullc_quantum;i++){\n\t\tdata[i] = test[i];\n\t}\n\tprintk(KERN_INFO \"cache: pos: %p, size: %d\\n\",scullc_cache, sizeof(scullc_cache));\n\tprintk(KERN_INFO \"data: pos:%p, size: %d, %s\\n\",data, sizeof(data), data);\n\treturn 0;\n}\nvoid __exit hello_world_exit(void)\n{\n\tkmem_cache_free(scullc_cache, data);\n\tkmem_cache_destroy(scullc_cache);\n\tprintk(KERN_INFO \"good bye, cache memory\\n\");\n\n}\nmodule_init(hello_world_init);\nmodule_exit(hello_world_exit);\nMODULE_LICENSE(\"GPL\");\nMODULE_AUTHOR(\"now0930\");\nMODULE_DESCRIPTION(\"cache memory test\");<\/pre>\n\n\n\n<p>cache \uba54\ubaa8\ub9ac\ub97c \uc5bc\ub9c8\ub098 \uc0ac\uc6a9\ud558\uace0 \uc788\ub294\uc9c0 \uc54c\uc544\ubcf4\ub294 \uc720\ud2f8\ub9ac\ud2f0\uac00 \uc788\uc744 \uac83 \uac19\uc740\ub370 \ubabb \ucc3e\uc558\ub2e4.<\/p>\n\n\n\n<p>\ucc38\uc870 \uc0ac\uc774\ud2b8<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.programiz.com\/c-programming\/c-structures-pointers\">struct and pointer<\/a><\/li><li><a href=\"http:\/\/egloos.zum.com\/rousalome\/v\/9964200\">crash utility for Arm<\/a><\/li><li><a href=\"http:\/\/egloos.zum.com\/rousalome\/v\/10092131\">curses.h \uc5c6\uc744 \uacbd\uc6b0<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>cache memroy \uc2e4\uc2b5 linux device driver, 8\uc7a5\uc744 \uc2e4\uc2b5 \ud588\ub2e4. \ucef4\ud30c\uc77c \ud558\uc5ec \uc2e4\ud589\ud558\uae30 \uc804\uc5d0\ub294 \uc5b4\ub5bb\uac8c \ub3cc\uc544\uac00\ub294\uc9c0 \uc798 \uc54c \uc218 \uc5c6\ub2e4. scullc\uc744 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12],"tags":[775,1025,949,1024],"class_list":["post-5006","post","type-post","status-publish","format-standard","hentry","category-12","tag-c","tag-cache","tag-driver","tag-memory"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/5006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=5006"}],"version-history":[{"count":4,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/5006\/revisions"}],"predecessor-version":[{"id":5010,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/5006\/revisions\/5010"}],"wp:attachment":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=5006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=5006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=5006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}