Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Conflito de Escrita em Matriz
#include <stdio.h> #include <stdlib.h> #include <pthread.h> int matriz[4][4]; void* funcaoA() { matriz[0][0] = matriz[0][0] + 10; return NULL; } void* funcaoB() { matriz[0][0] = matriz[0][0] * 2; return NULL; } void zerarMatriz() { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { matriz[x][y] = 0; } } } int main() { for (int i = 0; i < 10; i++) { zerarMatriz(); pthread_t threadA, threadB; pthread_create(&threadA, NULL, funcaoA, NULL); pthread_create(&threadB, NULL, funcaoB, NULL); pthread_join(threadA, NULL); pthread_join(threadB, NULL); printf("Resultado %d\n", matriz[0][0]); } return 0; }
run
|
edit
|
history
|
help
0
---DISEÑO DE TECLADO---
sample
BMI Calc CT
Even odd program
sjf
Exploiting uninitialized variable
Thread and Mutex Code
Lab 5 HW Spring 2017 v1.1
A_141125_MenorMayor2
PREGUNTA 2 EXAMEN