aboutsummaryrefslogtreecommitdiff
path: root/common/io.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-01-02 12:08:59 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-01-02 12:08:59 +0100
commit7aab8f34e8a238ce0688bf9f7e7f0b731902580f (patch)
tree6ab0541168d07c2755c51d9ef6875012105816e8 /common/io.c
parent280dace8bf97242151faf8297af31de67f77085c (diff)
downloadphilosophers-7aab8f34e8a238ce0688bf9f7e7f0b731902580f.tar.gz
philosophers-7aab8f34e8a238ce0688bf9f7e7f0b731902580f.tar.bz2
philosophers-7aab8f34e8a238ce0688bf9f7e7f0b731902580f.zip
Updated philo_two with philo_three logic, Norming philo_two and philo_three
Diffstat (limited to 'common/io.c')
-rw-r--r--common/io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/io.c b/common/io.c
index 48bb8cc..cbaa69f 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: 2020/10/05 15:29:09 by cacharle ### ########.fr */
+/* Updated: 2021/01/02 12:08:16 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -42,10 +42,13 @@ static void st_strcat(char *dst, char *str)
void philo_put(size_t id, t_philo_event event)
{
- static char buf[2048];
+ 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());
+ st_nbrcpy(buf, h_time_now() - initial_time);
st_strcat(buf, " ");
st_nbrcpy(buf + st_strlen(buf), id);
if (event == EVENT_FORK)