tgrekov-philosophers
HIVE philosophers July 2024
Loading...
Searching...
No Matches
seat.c File Reference

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* seat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/02 07:20:21 by tgrekov #+# #+# */
/* Updated: 2024/08/06 17:10:30 by tgrekov ### ########.fr */
/* */
/* ************************************************************************** */

Definition in file seat.c.

#include <stdlib.h>
#include <unistd.h>
#include "../philosopher/philo.h"
Include dependency graph for seat.c:

Go to the source code of this file.

Functions

int setup (t_global *global, t_thread **thread)
 Allocate fork array and thread structure, initialize mutexes.
 
void * breakfast (void *data)
 Ponder, eat, sleep, repeat.
 
static void monitor_eat_quota (t_global *global, t_thread *thread, int i)
 End simulation once all philos are full.
 
static int create_threads (t_global *global, t_thread *thread)
 Spawn philos and wait for them to complete.
 
int seat (t_opt opt)
 Allocate for, initialize, seat, wait on (pun intended), and free all philos.
 

Function Documentation

◆ breakfast()

void * breakfast ( void *  arg)

Ponder, eat, sleep, repeat.

Parameters
arg
Return values
void*

Definition at line 65 of file breakfast.c.

References eat(), philo_sleep(), status(), and stop().

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

◆ create_threads()

static int create_threads ( t_global global,
t_thread thread 
)
static

Spawn philos and wait for them to complete.

Parameters
global
thread
Return values
int

Definition at line 54 of file seat.c.

References breakfast(), err(), and monitor_eat_quota().

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

◆ monitor_eat_quota()

static void monitor_eat_quota ( t_global global,
t_thread thread,
int  i 
)
static

End simulation once all philos are full.

Parameters
global
thread
i

Definition at line 34 of file seat.c.

Here is the caller graph for this function:

◆ seat()

int seat ( t_opt  opt)

Allocate for, initialize, seat, wait on (pun intended), and free all philos.

Parameters
opt
Return values
int

Definition at line 90 of file seat.c.

References create_threads(), and setup().

Here is the call graph for this function:

◆ setup()

int setup ( t_global global,
t_thread **  thread 
)

Allocate fork array and thread structure, initialize mutexes.

Parameters
global
thread
Return values
int

Definition at line 84 of file setup.c.

References allocate(), and initialize().

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