-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.c
69 lines (51 loc) · 1.07 KB
/
app.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "sbmem.h"
#include <stdio.h>
#include <stdlib.h>
#include <semaphore.h>
#include <sys/mman.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "math.h"
void test(){
int ret = sbmem_open();
if (ret == -1)
exit(1);
srand(time(NULL));
int rando;
char* ptrs[1];
for (int k = 0; k < 1; k++)
{
rando = (rand() % (4096 - 128)) + 128;
ptrs[k] = sbmem_alloc(rando);
}
for (int k = 0; k < 1; k++)
{
sbmem_free(ptrs[k]);
}
sbmem_close();
}
int main(){
int numProc = 200;
int pidlist[numProc];
for(int i = 0; i < numProc; i++){
pidlist[i] = fork();
if(pidlist[i] == 0) {
test();
exit(1);
break;
}
}
for ( int i = 0; i < numProc; i++)
{
waitpid(pidlist[i],NULL,0);
}
return 0;
}