-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulation.c
More file actions
40 lines (37 loc) · 1.38 KB
/
Copy pathsimulation.c
File metadata and controls
40 lines (37 loc) · 1.38 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* simulation.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mehdemir <mehdemir@student.42berlin.d +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/20 13:25:27 by mehdemir #+# #+# */
/* Updated: 2026/04/20 13:25:29 by mehdemir ### ########.fr */
/* */
/* ************************************************************************** */
#include "codexion.h"
int start_simulation(t_env *env)
{
pthread_t monitor;
int i;
i = 0;
env->start_time = get_time_ms();
while (i < env->num_coders)
{
if (
pthread_create(&env->coders[i].thread,
NULL, &coder_routine, &env->coders[i]) != 0)
return (FAILURE);
i++;
}
if (pthread_create(&monitor, NULL, &monitor_routine, env) != 0)
return (FAILURE);
i = 0;
while (i < env->num_coders)
{
pthread_join(env->coders[i].thread, NULL);
i++;
}
pthread_join(monitor, NULL);
return (SUCCESS);
}