aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-01-03 14:04:22 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-01-03 14:04:22 +0100
commite874ad94a31a8259b8eb7ad2865767c081bcd279 (patch)
treee629a6cef53b2c6cafcde9f8bbf5d1f7678753d6 /common
parent592c515b742222c637478b3339b95cd2de8b4379 (diff)
downloadphilosophers-e874ad94a31a8259b8eb7ad2865767c081bcd279.tar.gz
philosophers-e874ad94a31a8259b8eb7ad2865767c081bcd279.tar.bz2
philosophers-e874ad94a31a8259b8eb7ad2865767c081bcd279.zip
Fixing philo_one/philo_two dying by sleeping more when checking the death, Fixing timestamp in the wrong order in philo_three
Diffstat (limited to 'common')
-rw-r--r--common/common.h5
-rw-r--r--common/io.c7
2 files changed, 5 insertions, 7 deletions
diff --git a/common/common.h b/common/common.h
index 30a00a2..617db1a 100644
--- a/common/common.h
+++ b/common/common.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 22:58:35 by cacharle #+# #+# */
-/* Updated: 2021/01/02 11:01:23 by cacharle ### ########.fr */
+/* Updated: 2021/01/03 14:02:38 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -61,6 +61,7 @@ int h_err(int ret, const char *format, char *str);
*/
void philo_put_set_initial_time(void);
-void philo_put(size_t id, t_philo_event event);
+void philo_put(
+ size_t id, t_philo_event event, t_time initial_time);
#endif
diff --git a/common/io.c b/common/io.c
index cbaa69f..5d50ccc 100644
--- a/common/io.c
+++ b/common/io.c
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/30 10:03:53 by cacharle #+# #+# */
-/* Updated: 2021/01/02 12:08:16 by cacharle ### ########.fr */
+/* Updated: 2021/01/03 14:02:21 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -40,13 +40,10 @@ static void st_strcat(char *dst, char *str)
*dst = '\0';
}
-void philo_put(size_t id, t_philo_event event)
+void philo_put(size_t id, t_philo_event event, t_time initial_time)
{
static char buf[2048];
- static t_time initial_time = -1;
- if (initial_time == -1)
- initial_time = h_time_now();
buf[0] = '\0';
st_nbrcpy(buf, h_time_now() - initial_time);
st_strcat(buf, " ");