#include #include #include "../../vmap.h" #define N 6 struct args { Memory* mem; int count; int size; int pid; }; void* thread(void* void_args) { struct args* args = (struct args*)void_args; Memory* mem = args->mem; int count = args->count; int size = args->size; int pid = args->pid; void** ptrs = malloc(sizeof(void*)*count); for (int i=0; i < count; i++) { ptrs[i] = my_malloc(mem, size, pid); } for (int i=0; i < count; i++) { my_free(mem, ptrs[i], pid); } free(ptrs); return NULL; } int main() { struct args* args = malloc(sizeof(struct args)); int pid = 12; Memory* mem = memory_init(pid); args->mem = mem; args->pid = pid; args->count = 20; args->size = 4; pthread_t tid[N]; for (int i=0; i < N; i++) { pthread_create(&(tid[i]), NULL, &thread, (void*)args); } for (int i=0; i < N; i++) { pthread_join(tid[i], NULL); } return 0; }