#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <omp.h>
#define MAX_NT 4
void
thread_work(int id)
{
clock_t t1, t2;
printf("Watek %d zaczyna prace...\n", id - 1);
t1 = clock();
do {
t2 = clock();
}
while ((((double)t2 - t1) / CLOCKS_PER_SEC) < id);
}
int
main(void)
{
int id;
#pragma omp parallel num_threads(MAX_NT) private(id)
{
id = omp_get_thread_num();
thread_work(id + 1);
printf("Watek %d zakonczyl prace i czeka przy barierze...\n", id);
#pragma omp barrier
printf("Watek %d juz poza bariera.\n", id);
}
printf("Nacisnij dowolny klawisz....");
getchar();
return 0;
}
Comments
0 B
|👍
/👎