-
Notifications
You must be signed in to change notification settings - Fork 1
/
filling.c
44 lines (35 loc) · 1.01 KB
/
filling.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "v2p.h"
#include <sys/mman.h>
#define ALLOC_FLAG (MAP_PRIVATE | MAP_ANONYMOUS)
int main()
{
int n = 1;
printf("filling begins\n");
//char *v;
//ASSERT((v = (char *)mmap(0, ALLOC_SIZE * n, PROT_READ | PROT_WRITE, ALLOC_FLAG, -1, 0)) != MAP_FAILED);
//memset(v1, '9', ALLOC_SIZE * n);
// Allocate some memory to manipulate
int i;
int end = 352 * 256;
for (i=1;i<=end;i++){
size_t buf_size = ALLOC_SIZE * n + 1;
void *v = malloc(buf_size);
if(v == NULL)
{
printf("Failed to allocate memory for buffer\n");
exit(1);
}
/* Lock the page in memory
if(mlock(v, buf_size) == -1)
{
printf("Failed to lock page in memory");
exit(1);
}*/
// Add some data to the memory
memset(v, '9', buf_size);
printf("%d\n",i);
//printf("v addr: %p\n", v);
//uint64_t p = v2p(v);
//printf("p addr: %p\n", p);
}
}