__get_free_pages( GFP_KERNEL, order );

김승주의 이미지

어제 공부하는데 아래 문장에

"order = get_order(8192*10);" 부분이 이해가 안갑니다....

저기 8192 가 의미하는 것은 무엇인지..그리고 곱하기 10은 무엇을 의미하는지 모르겠습니다;;

buff = __get_free_pages( GFP_KERNEL, order ); 함수랑 관계가 있다고 하는데

책에는 설명이 차수를 대신 계산해서 order에 넣어준다고 나와 있거든요..

그런데 차수가 무엇을 말하는지 모르겠어요...

도대체 개념이 안서니깐;;ㅠ

아시는 분 좀 가르쳐 주세요...

아래는 원문입니다..

##################################################################################

#define MODULE
#include
#include

#include
#include
#include

void kmalloc_test( void )
{
char *buff;

printk( "kmalloc test\n" );

buff = kmalloc( 1204, GFP_KERNEL );
if( buff != NULL )
{
sprintf( buff, "Small Memory Ok\n" );
printk( buff );

kfree( buff );
}

buff = kmalloc( 32 * PAGE_SIZE, GFP_KERNEL );
if( buff != NULL )
{
printk( "Big Memory Ok\n" );
kfree( buff );
}

}

void vmalloc_test( void )
{
char *buff;

printk( "vmalloc test\n" );

buff = vmalloc( 33 * PAGE_SIZE );
if( buff != NULL )
{
sprintf( buff, "vmalloc test ok\n" );
printk( buff );

vfree( buff );
}

}

void get_free_pages_test( void )
{
char *buff;
int order;

printk( "get_free_pages test\n" );

order = get_order(8192*10);
buff = __get_free_pages( GFP_KERNEL, order );
if( buff != NULL)
{
sprintf( buff, "__get_free_pages test ok [%d]\n", order );
printk( buff );

free_pages(buff, order);
}
}

int init_module(void)
{
char *data;

printk("Module Memory Test\n" );

kmalloc_test();
vmalloc_test();
get_free_pages_test();

return 0;
}

void cleanup_module(void)
{
printk("Module Memory Test End\n");
}


#####################################################################################

bummi의 이미지

__get_free_pages
이 펑션은 물리적으로 연속된 메모리를 가져올때 주로 사용합니다

우선 리눅스에서는 메모리를 PAGE_SIZE (4kbyte)로 관리하는건 하시는건 아시죠?
리눅스에서 사용하지 않는 물리메모리 관리는 외부 단편화를 줄이기 위해 Buddy system(버디 알고리즘)을 사용하는데

이 버디 시스템이 메모리를 관리할때 PAGE_SIZE * 2의 x자승(- -;;)으로 비어 있는 물리 메모리를 관리하게
됩니다.

위 Function의 경우 buddy system에게 메모리를 요구하기 때문에 order 즉 위에서 말하는 x값 단위로
메모리를 요구하게 됩니다.

수고하세요

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.