osproject_thread.c 754 Bytes
#include<stdio.h>
#include<string.h>
#include<pthread.h>
#include<stdlib.h>
#include<unistd.h>
pthread_t tid[100];
void* doSomeThing(void *arg)
{
}
int main(void)
{
int i = 0;
int err;
int avg = 0;
int a, b;
printf("Entering the thing\n");
asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (err));
printf("regr: %x\n", err);
while(i < 100) {
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a));
err = pthread_create(&(tid[i]), NULL, &doSomeThing, NULL);
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
if (err != 0)
printf("Error in thread creation\n");
//printf("Time for fork: %u\n", b - a);
avg += (b - a);
pthread_cancel(tid[i]);
i++;
}
printf("Avg thread creation time is %d\n", avg/100);
return 1;
}