blob: 5b84be9975434e09a39ae84bc6ba58c55a95b199 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "codexion.h"
# include <stdlib.h> // for atoi(), malloc()
t_sim *create_sim(char **argv)
{
t_sim *sim;
sim = NULL;
sim = (t_sim *)malloc(sizeof(t_sim));
if (!sim)
return (NULL);
sim->number_of_philos = atoi(argv[1]);
sim->time_to_starve = atoi(argv[2]);
sim->time_to_eat = atoi(argv[3]);
sim->time_to_reflect = atoi(argv[4]);
sim->time_to_think = atoi(argv[5]);
sim->number_of_eat_required = atoi(argv[6]);
sim->philo_starved = 0;
sim->fork_cooldown = atoi(argv[7]);
sim->scheduler = argv[8];
sim->start_time = 0;
return (sim);
}
|