// Compile with: // gcc -Wall -g -o sched_bind schedBind.c -lpthread #include /* needs to be before stdio.h */ #include #include //#include //#include #include #include #include #include #include _syscall0(pid_t,gettid) pid_t gettid(void); #define SIZE 7000 #define TIMES 10000 int arr[4][SIZE]; int idx; void* compute_thread(void*); int main(void) { int i; pthread_t tid[8]; /* thread ID structure */ pthread_attr_t attr; /* thread attributes */ char thread[4][4] ={"0", "1", "2", "3"}; /* Initialize thread attribute structure */ //pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); // default anyway. for (idx = 0; idx < 8; idx++ ) { pthread_attr_init(&attr); pthread_create(&(tid[idx]), &attr, compute_thread, thread[(idx/2)]); } /* main thread */ for (i= 0; i<8; i++) pthread_join(tid[i], NULL); printf("Main exit ...\n"); exit(0); } /* The thread function to be run */ void* compute_thread(void* dummy) { int i,j; int procNum; // int res; procNum = atoi((char *)dummy); printf("Thread DS %d TID = %d\n", procNum, gettid()); for (j=0; j