summaryrefslogtreecommitdiff
path: root/src/sim.c
diff options
context:
space:
mode:
authoryctct <yctct@yctct.com>2026-09-13 18:58:14 +0200
committeryctct <yctct@yctct.com>2026-09-13 18:58:14 +0200
commit47beba686ff9d2aab63738fba7176a5235703d05 (patch)
treef839ed36a9e9d4476fcdc59379b17903abfa35c8 /src/sim.c
Add all files, first commit
Diffstat (limited to 'src/sim.c')
-rw-r--r--src/sim.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sim.c b/src/sim.c
new file mode 100644
index 0000000..5b84be9
--- /dev/null
+++ b/src/sim.c
@@ -0,0 +1,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);
+}