File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ int consume_pm_MB(size_t M)
8
8
{
9
9
void * block ;
10
10
void * tmpblock ;
11
- size_t blocksize []= {1024 * 1024 , 1024 , 1 };
11
+ size_t blocksize []= {1024 * 1024 , 1024 , 1 };
12
12
int i ,count ;
13
13
14
14
size_t maximum = 0 ;
@@ -24,9 +24,9 @@ int consume_pm_MB(size_t M)
24
24
free (block );
25
25
}else {
26
26
break ;
27
- }
28
- }
29
- }
27
+ }
28
+ }
29
+ }
30
30
printf ("maximum malloc size = %lf MB\n" ,tmpmaximum * 1.0 / 1024.0 / 1024.0 );
31
31
printf ("the address is [%p, %p)\n" , tmpblock , (char * )tmpblock + tmpmaximum );
32
32
tmpblock = malloc (maximum );
@@ -39,6 +39,7 @@ int consume_pm_MB(size_t M)
39
39
}
40
40
41
41
int page = 0 ;
42
+ //one page frame=4KB (1MB=256Pages)
42
43
for (page = 0 ; page < 256 * M ;page ++ )
43
44
{
44
45
printf ("initialize page %d\n" , page );
@@ -49,7 +50,7 @@ int consume_pm_MB(size_t M)
49
50
size_t maximum = 0 ;
50
51
int main (int argc ,char * argv [])
51
52
{
52
- consume_pm_MB (340 );
53
+ consume_pm_MB (2000 );
53
54
while (1 )
54
55
sleep (1 );
55
56
}
You can’t perform that action at this time.
0 commit comments