I am writing a C program using <pthread.h> .
pthreadobjects - the structure passed to the thread.
int main{ ... Pthreadobjects = (pthreadobject *)malloc(allthreads * sizeof(pthreadobject)); pthread_barrier_init(&globalblock, NULL, allthreads + 1); //ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΠΎΠ²Π°Π»ΠΈ //ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ Π±Π°ΡΡΠ΅ΡΠ° Pthreadobjects[i].globalblock = &globalblock; // ΠΏΠ΅ΡΠ΅Π΄Π°Π»ΠΈ ΡΡΡΡΠΊΡΡΡΠ΅ ΡΠΊΠ°Π·Π°ΡΠ΅Π»Ρ pthread_create(Pthreads + i, NULL, &pthreadfunc, Pthreadobjects + i); pthread_barrier_wait(&globalblock); //ΠΆΠ΄ΡΠΌ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Π½ΠΈΡΠ΅ΠΉ ... } void * pthreadfunc(void * elem){ //ΡΡΠ½ΠΊΡΠΈΡ Π΄Π»Ρ Π½ΠΈΡΠΈ pthreadobject * PTHO = elem; pthread_barrier_wait(PTHO -> globalblock); return 0; } When you start the program gives a certain answer, finishes the calculations, but sometimes the following error occurs:
The futex facility returned an unexpected error code.
What am I doing wrong?