forked from e5l/au-linux-kernel-spring-2016
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa6af24
commit 3ad6d27
Showing
2 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
#include<sys/mman.h> | ||
#include<stdio.h> | ||
|
||
int main() | ||
{ | ||
// TODO | ||
return 0; | ||
|
||
size_t bytes_to_allocate = 1; | ||
void* res = NULL; | ||
while (res != MAP_FAILED) | ||
{ | ||
void* addr = mmap(NULL, bytes_to_allocate, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); | ||
bytes_to_allocate *= 2; | ||
res = addr; | ||
} | ||
|
||
size_t bytes_to_allocate1 = bytes_to_allocate / 2; | ||
while (res != MAP_FAILED) | ||
{ | ||
void* addr = mmap(NULL, bytes_to_allocate1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); | ||
bytes_to_allocate1 /= 2; | ||
res = addr; | ||
} | ||
|
||
printf("Allocated: %zu bytes of memory\n", bytes_to_allocate + bytes_to_allocate1); | ||
return 0; | ||
} |
Binary file not shown.