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 # 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 # Variables
@ -16,6 +16,9 @@ make all --print-data-base --no-builtin-variables --no-builtin-rules --question
<D = $(patsubst %/,%,$(dir $<)) <D = $(patsubst %/,%,$(dir $<))
# automatic # automatic
?F = $(notdir $?) ?F = $(notdir $?)
make: *** No rule to make target `all'. Stop.
# environment # environment
VSCODE_LOG_NATIVE = false VSCODE_LOG_NATIVE = false
# automatic # automatic
@ -39,16 +42,13 @@ VSCODE_NODE_CACHED_DATA_DIR = /Users/mdenys/Library/Application Support/Code/Cac
# environment # environment
VSCODE_VERBOSE_LOGGING = true VSCODE_VERBOSE_LOGGING = true
# environment # 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 # environment
VSCODE_CWD = / VSCODE_CWD = /
# environment # environment
Apple_PubSub_Socket_Render = /private/tmp/com.apple.launchd.EPpFRNecPx/Render Apple_PubSub_Socket_Render = /private/tmp/com.apple.launchd.EPpFRNecPx/Render
# environment # 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 PATH = /Users/mdenys/.brew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/Library/Frameworks/Mono.framework/Versions/Current/Commands
make: *** No rule to make target `all'. Stop.
# environment # environment
VSCODE_LOG_STACK = false VSCODE_LOG_STACK = false
# environment # environment
@ -83,32 +83,24 @@ VSCODE_HANDLES_UNCAUGHT_ERRORS = true
^D = $(patsubst %/,%,$(dir $^)) ^D = $(patsubst %/,%,$(dir $^))
# environment # environment
XPC_FLAGS = 0x0 XPC_FLAGS = 0x0
# environment
COLORTERM = truecolor
# default # default
MAKE = $(MAKE_COMMAND) MAKE = $(MAKE_COMMAND)
# environment # default
LC_TERMINAL = iTerm2 MAKECMDGOALS := all
# environment # environment
HOMEBREW_CACHE = /tmp/mdenys/Homebrew/Caches HOMEBREW_CACHE = /tmp/mdenys/Homebrew/Caches
# environment # environment
SHLVL = 2 SHLVL = 1
# default # default
MAKE_VERSION := 3.81 MAKE_VERSION := 3.81
# environment # environment
USER = mdenys USER = mdenys
# makefile # makefile
.DEFAULT_GOAL := .DEFAULT_GOAL :=
# default
MAKECMDGOALS := all
# environment
TERM_SESSION_ID = w0t0p0:520B77F0-CFEA-4D37-8A86-B45CDD412BEF
# automatic # automatic
%D = $(patsubst %/,%,$(dir $%)) %D = $(patsubst %/,%,$(dir $%))
# default # default
MAKE_COMMAND := /Applications/Xcode.app/Contents/Developer/usr/bin/make MAKE_COMMAND := /Applications/Xcode.app/Contents/Developer/usr/bin/make
# environment
TERM_PROGRAM = iTerm.app
# default # default
.VARIABLES := .VARIABLES :=
# environment # environment
@ -124,28 +116,18 @@ MFLAGS = -Rrqp
# automatic # automatic
*D = $(patsubst %/,%,$(dir $*)) *D = $(patsubst %/,%,$(dir $*))
# environment # environment
TERM_PROGRAM_VERSION = 3.3.7
# environment
XPC_SERVICE_NAME = com.microsoft.VSCode.1224 XPC_SERVICE_NAME = com.microsoft.VSCode.1224
# environment
LC_TERMINAL_VERSION = 3.3.7
# automatic # automatic
+D = $(patsubst %/,%,$(dir $+)) +D = $(patsubst %/,%,$(dir $+))
# automatic # automatic
+F = $(notdir $+) +F = $(notdir $+)
# environment # environment
ITERM_SESSION_ID = w0t0p0:520B77F0-CFEA-4D37-8A86-B45CDD412BEF
# environment
COLORFGBG = 7;0
# environment
__CF_USER_TEXT_ENCODING = 0xF70C8:0x0:0x0 __CF_USER_TEXT_ENCODING = 0xF70C8:0x0:0x0
# default # default
MAKEFILES := MAKEFILES :=
# automatic # automatic
<F = $(notdir $<) <F = $(notdir $<)
# environment # environment
ITERM_PROFILE = Default
# environment
LC_ALL = C LC_ALL = C
# automatic # automatic
^F = $(notdir $^) ^F = $(notdir $^)
@ -158,11 +140,9 @@ MAKELEVEL := 0
# environment # environment
LANG = C LANG = C
# environment # environment
TERM = xterm-256color VSCODE_PID = 91790
# environment
VSCODE_PID = 96474
# variable set hash-table stats: # 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 # Pattern-specific Variable Values
@ -170,9 +150,9 @@ VSCODE_PID = 96474
# Directories # 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 # Implicit Rules
@ -244,6 +224,6 @@ GNUmakefile:
# strcache size: total = 0 / max = 0 / min = 4096 / avg = 0 # strcache size: total = 0 / max = 0 / min = 4096 / avg = 0
# strcache free: 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 typedef struct s_philo
{ {
int right_fork; int more_fork;
int left_fork; int less_fork; // TODO переделать на наименьшую и наибольшую
pthread_t *thread;
int count_eat;
time_t time_to_die;
pthread_mutex_t *eat_mutex;
} t_philo; } t_philo;
typedef struct s_philo_data 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 ft_atoi(const char *str);
int check_f(char ch); int check_f(char ch);
int runner(t_all *all, int optional); int runner(t_all *all, int optional);
int return_big(int a, int b);
int return_less(int a, int b);
#endif #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) if (i == 0)
{ {
all->data_philo->philors[i].left_fork = all->number_of_philosophers; all->data_philo->philors[i].more_fork = all->number_of_philosophers;
all->data_philo->philors[i].right_fork = 0; all->data_philo->philors[i].less_fork = 0;
} }
else else
{ {
all->data_philo->philors[i].left_fork = i; all->data_philo->philors[i].more_fork = return_big(i, i + 1);
all->data_philo->philors[i].right_fork = i + 1; all->data_philo->philors[i].less_fork = return_less(i, i + 1);
} }
i++; i++;
} }
@ -73,12 +73,23 @@ int prepare_resources(t_all *all)
return (0); return (0);
} }
void run_all_philor(t_all *all)
{
}
// void run_observer(t_all *all)
// {
// }
int runner(t_all *all, int optional) int runner(t_all *all, int optional)
{ {
if (optional) if (optional)
{ {
// func_test(all);
prepare_resources(all); prepare_resources(all);
run_all_philor(all);
// run_observer(all);
return(0); return(0);
} }
else else

View File

@ -68,3 +68,21 @@ t_all *structalloc_and_bzero(void)
all->number_of_times_each_philosopher_must_eat = -1; all->number_of_times_each_philosopher_must_eat = -1;
return(all); 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);
}