tgrekov-philosophers
HIVE philosophers July 2024
Loading...
Searching...
No Matches
philo.h File Reference

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* philo.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/22 04:59:35 by tgrekov #+# #+# */
/* Updated: 2024/08/06 17:14:22 by tgrekov ### ########.fr */
/* */
/* ************************************************************************** */

Definition in file philo.h.

#include <pthread.h>
Include dependency graph for philo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_opt
 
struct  t_global
 
struct  s_thread
 

Functions

int philo_sleep (unsigned long ms, t_thread *thread)
 Sleep in 200 microsecond intervals until ms millis have elapsed, or stop has returned non-zero.
 
int status (t_thread *thread, char *str, int ignore_end)
 Thread safe philosopher state logging.
 
int check_end (t_global *global)
 Check if the simulation has ended.
 
int stop (t_thread *thread)
 Determine if this thread's philo should die, or if the thread has reported an error.
 

Function Documentation

◆ check_end()

int check_end ( t_global global)

Check if the simulation has ended.

Parameters
global
Return values
int

Definition at line 28 of file sim_end.c.

Here is the caller graph for this function:

◆ philo_sleep()

int philo_sleep ( unsigned long  ms,
t_thread thread 
)

Sleep in 200 microsecond intervals until ms millis have elapsed, or stop has returned non-zero.

Parameters
msMilliseconds to sleep
thread
Return values
int

Definition at line 33 of file philo_sleep.c.

References check_end(), stop(), and timestamp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ status()

int status ( t_thread thread,
char *  str,
int  ignore_end 
)

Thread safe philosopher state logging.

Parameters
thread
str
ignore_end
Return values
int

Definition at line 46 of file status.c.

References check_end(), status_print_verify(), and timestamp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

int stop ( t_thread thread)

Determine if this thread's philo should die, or if the thread has reported an error.

Parameters
thread
Return values
int

Definition at line 30 of file stop.c.

References status(), and timestamp().

Here is the call graph for this function:
Here is the caller graph for this function: