This commit is contained in:
Matthos Denys 2021-05-13 12:23:30 +03:00
parent 7790cc4944
commit 106eb67fa5
9 changed files with 56 additions and 41 deletions

48
.vscode/targets.log vendored
View File

@ -8,7 +8,7 @@ make all --print-data-base --no-builtin-variables --no-builtin-rules --question
# This program built for i386-apple-darwin11.3.0
# Make data base, printed on Wed May 12 17:25:51 2021
# Make data base, printed on Thu May 13 12:04:43 2021
# Variables
@ -16,6 +16,9 @@ make all --print-data-base --no-builtin-variables --no-builtin-rules --question
<D = $(patsubst %/,%,$(dir $<))
# automatic
?F = $(notdir $?)
make: *** No rule to make target `all'. Stop.
# environment
VSCODE_LOG_NATIVE = false
# automatic
@ -39,16 +42,13 @@ VSCODE_NODE_CACHED_DATA_DIR = /Users/mdenys/Library/Application Support/Code/Cac
# environment
VSCODE_VERBOSE_LOGGING = true
# environment
VSCODE_IPC_HOOK_EXTHOST = /var/folders/zz/zyxvpxvq6csfxvn_n003vhs000yw68/T/vscode-ipc-5e87255d-4c59-4ce0-938f-d9af1a63e1c5.sock
VSCODE_IPC_HOOK_EXTHOST = /var/folders/zz/zyxvpxvq6csfxvn_n003vhs000yw68/T/vscode-ipc-c1d2049e-7cbe-449e-8843-c482df06e729.sock
# environment
VSCODE_CWD = /
# environment
Apple_PubSub_Socket_Render = /private/tmp/com.apple.launchd.EPpFRNecPx/Render
# environment
PATH = /Users/mdenys/.brew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/mdenys/.brew/bin
make: *** No rule to make target `all'. Stop.
PATH = /Users/mdenys/.brew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/Library/Frameworks/Mono.framework/Versions/Current/Commands
# environment
VSCODE_LOG_STACK = false
# environment
@ -83,32 +83,24 @@ VSCODE_HANDLES_UNCAUGHT_ERRORS = true
^D = $(patsubst %/,%,$(dir $^))
# environment
XPC_FLAGS = 0x0
# environment
COLORTERM = truecolor
# default
MAKE = $(MAKE_COMMAND)
# environment
LC_TERMINAL = iTerm2
# default
MAKECMDGOALS := all
# environment
HOMEBREW_CACHE = /tmp/mdenys/Homebrew/Caches
# environment
SHLVL = 2
SHLVL = 1
# default
MAKE_VERSION := 3.81
# environment
USER = mdenys
# makefile
.DEFAULT_GOAL :=
# default
MAKECMDGOALS := all
# environment
TERM_SESSION_ID = w0t0p0:520B77F0-CFEA-4D37-8A86-B45CDD412BEF
# automatic
%D = $(patsubst %/,%,$(dir $%))
# default
MAKE_COMMAND := /Applications/Xcode.app/Contents/Developer/usr/bin/make
# environment
TERM_PROGRAM = iTerm.app
# default
.VARIABLES :=
# environment
@ -124,28 +116,18 @@ MFLAGS = -Rrqp
# automatic
*D = $(patsubst %/,%,$(dir $*))
# environment
TERM_PROGRAM_VERSION = 3.3.7
# environment
XPC_SERVICE_NAME = com.microsoft.VSCode.1224
# environment
LC_TERMINAL_VERSION = 3.3.7
# automatic
+D = $(patsubst %/,%,$(dir $+))
# automatic
+F = $(notdir $+)
# environment
ITERM_SESSION_ID = w0t0p0:520B77F0-CFEA-4D37-8A86-B45CDD412BEF
# environment
COLORFGBG = 7;0
# environment
__CF_USER_TEXT_ENCODING = 0xF70C8:0x0:0x0
# default
MAKEFILES :=
# automatic
<F = $(notdir $<)
# environment
ITERM_PROFILE = Default
# environment
LC_ALL = C
# automatic
^F = $(notdir $^)
@ -158,11 +140,9 @@ MAKELEVEL := 0
# environment
LANG = C
# environment
TERM = xterm-256color
# environment
VSCODE_PID = 96474
VSCODE_PID = 91790
# variable set hash-table stats:
# Load=73/1024=7%, Rehash=0, Collisions=4/94=4%
# Load=63/1024=6%, Rehash=0, Collisions=1/84=1%
# Pattern-specific Variable Values
@ -170,9 +150,9 @@ VSCODE_PID = 96474
# Directories
# . (device 16777227, inode 5034668): 7 files, no impossibilities.
# . (device 16777227, inode 5034668): 8 files, no impossibilities.
# 7 files, no impossibilities in 1 directories.
# 8 files, no impossibilities in 1 directories.
# Implicit Rules
@ -244,6 +224,6 @@ GNUmakefile:
# strcache size: total = 0 / max = 0 / min = 4096 / avg = 0
# strcache free: total = 0 / max = 0 / min = 4096 / avg = 0
# Finished Make data base on Wed May 12 17:25:51 2021
# Finished Make data base on Thu May 13 12:04:43 2021

View File

@ -11,8 +11,12 @@
typedef struct s_philo
{
int right_fork;
int left_fork;
int more_fork;
int less_fork; // TODO переделать на наименьшую и наибольшую
pthread_t *thread;
int count_eat;
time_t time_to_die;
pthread_mutex_t *eat_mutex;
} t_philo;
typedef struct s_philo_data
@ -37,5 +41,7 @@ int parse_and_check_values(char **argv, int quantity);
int ft_atoi(const char *str);
int check_f(char ch);
int runner(t_all *all, int optional);
int return_big(int a, int b);
int return_less(int a, int b);
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -44,13 +44,13 @@ void get_fork_for_philo(t_all *all)
{
if (i == 0)
{
all->data_philo->philors[i].left_fork = all->number_of_philosophers;
all->data_philo->philors[i].right_fork = 0;
all->data_philo->philors[i].more_fork = all->number_of_philosophers;
all->data_philo->philors[i].less_fork = 0;
}
else
{
all->data_philo->philors[i].left_fork = i;
all->data_philo->philors[i].right_fork = i + 1;
all->data_philo->philors[i].more_fork = return_big(i, i + 1);
all->data_philo->philors[i].less_fork = return_less(i, i + 1);
}
i++;
}
@ -73,12 +73,23 @@ int prepare_resources(t_all *all)
return (0);
}
void run_all_philor(t_all *all)
{
}
// void run_observer(t_all *all)
// {
// }
int runner(t_all *all, int optional)
{
if (optional)
{
// func_test(all);
prepare_resources(all);
run_all_philor(all);
// run_observer(all);
return(0);
}
else

View File

@ -68,3 +68,21 @@ t_all *structalloc_and_bzero(void)
all->number_of_times_each_philosopher_must_eat = -1;
return(all);
}
int return_big(int a, int b)
{
if (a > b)
{
return (a);
}
return (b);
}
int return_less(int a, int b)
{
if (a < b)
{
return (a);
}
return (b);
}