-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreadtest.c
42 lines (36 loc) · 824 Bytes
/
threadtest.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
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <stdio.h>
#include "maMalloc.h"
void *func() {
printf("Inside thread 1\n");
void *p = maMalloc(50);
void *p1 = maRealloc(p, 100);
monFree(p);
printf("-----Thread 1 Done----\n");
return NULL;
}
void *func1() {
printf("Inside thread 2\n");
void *p = maMalloc(50);
void *p1 = maMalloc(200);
void *p2 = maMalloc(200);
void *p3 = maMalloc(5000);
void *p4 = maRealloc(p2, 300);
monFree(p4);
printf("-----Thread 2 Done----\n");
return NULL;
}
int main() {
pthread_t t1, t2, t3;
pthread_create(&t1, NULL, func, NULL);
pthread_create(&t2, NULL, func1, NULL);
pthread_create(&t3, NULL, func, NULL);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
pthread_join(t3, NULL);
/*Malloc_stats();*/
return 0;
}