tgrekov-philosophers
HIVE philosophers July 2024
Loading...
Searching...
No Matches
stop.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* stop.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/07/27 07:06:01 by tgrekov #+# #+# */
9/* Updated: 2024/08/06 17:19:52 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
20#include "../utils/utils.h"
21#include "philo.h"
22
30int stop(t_thread *thread)
31{
32 if (thread->err)
33 return (1);
34 if (timestamp() - thread->last_meal
35 >= (unsigned long) thread->global->opt.tt_die)
36 {
37 if (!set_end(thread->global))
38 thread->err = status(thread, "died", 1);
39 return (1);
40 }
41 return (0);
42}
int status(t_thread *thread, char *str, int ignore_end)
Thread safe philosopher state logging.
Definition status.c:46
int stop(t_thread *thread)
Determine if this thread's philo should die, or if the thread has reported an error.
Definition stop.c:30
unsigned long timestamp(void)
Millisecond timestamp since this function was first called.
Definition timestamp.c:27