Skip to content

Commit 721f986

Browse files
author
Wang Jiazi
committed
add comments
1 parent 5d31bfb commit 721f986

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Linux/Memory/pm_consumer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int consume_pm_MB(size_t M)
88
{
99
void * block;
1010
void * tmpblock;
11-
size_t blocksize[]={1024*1024, 1024, 1};
11+
size_t blocksize[]={1024*1024, 1024, 1};
1212
int i,count;
1313

1414
size_t maximum=0;
@@ -24,9 +24,9 @@ int consume_pm_MB(size_t M)
2424
free(block);
2525
}else{
2626
break;
27-
}
28-
}
29-
}
27+
}
28+
}
29+
}
3030
printf("maximum malloc size = %lf MB\n",tmpmaximum*1.0 / 1024.0 / 1024.0);
3131
printf("the address is [%p, %p)\n", tmpblock, (char*)tmpblock+tmpmaximum);
3232
tmpblock = malloc(maximum);
@@ -39,6 +39,7 @@ int consume_pm_MB(size_t M)
3939
}
4040

4141
int page = 0;
42+
//one page frame=4KB (1MB=256Pages)
4243
for(page=0; page<256*M;page++)
4344
{
4445
printf("initialize page %d\n", page);
@@ -49,7 +50,7 @@ int consume_pm_MB(size_t M)
4950
size_t maximum=0;
5051
int main(int argc,char *argv[])
5152
{
52-
consume_pm_MB(340);
53+
consume_pm_MB(2000);
5354
while(1)
5455
sleep(1);
5556
}

0 commit comments

Comments
 (0)