-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
51 lines (39 loc) · 1.23 KB
/
main.c
File metadata and controls
51 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "Professor/professor.h"
#include "AlunosSO/alunos_so.h"
#include "AlunosDuvidas/alunos_duvidas.h"
#include "resource_monitor.h"
int main()
{
pthread_t professor;
pthread_t alunos_so[NUM_ALUNOS_SO];
pthread_t alunos_duvida[NUM_ALUNOS_DUVIDA];
// Inicializa o monitor
initMonitor();
// professor
pthread_create(&professor, NULL, (void *)professorThread, NULL);
// alunos_so
for(int i=1; i <= NUM_ALUNOS_SO; i++) {
pthread_create(&(alunos_so[i]), NULL, (void *)alunosSOThread, (void *)(intptr_t)(i));
}
// alunos_duvida
for(int i=1; i <= NUM_ALUNOS_DUVIDA; i++) {
pthread_create(&(alunos_duvida[i]), NULL, (void *)alunosDuvidasThread, (void *)(intptr_t)(i));
}
// // Espera as threads alunos_so acabarem
// for (int i=1; i <= NUM_ALUNOS_SO; i++) {
// pthread_join(alunos_so[i],NULL);
// }
// // espera as threads aluno_duvida acabarem
// for (int i=1; i <= NUM_ALUNOS_DUVIDA; i++) {
// pthread_join(alunos_duvida[i],NULL);
// }
// espera o professor acabar
pthread_join(professor, NULL);
// Destroi o monitor
destroyMonitor();
printf("\n");
return 0;
}