diff --git a/.vscode/configurationCache.log b/.vscode/configurationCache.log index 02749e8..bab9054 100644 --- a/.vscode/configurationCache.log +++ b/.vscode/configurationCache.log @@ -1 +1 @@ -{"buildTargets":["all"],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}} \ No newline at end of file +{"buildTargets":[],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}} \ No newline at end of file diff --git a/.vscode/dryrun.log b/.vscode/dryrun.log index 5dbd0b2..a76ff7a 100644 --- a/.vscode/dryrun.log +++ b/.vscode/dryrun.log @@ -1,6 +1,7 @@ -make all --dry-run --keep-going --print-directory -make: Entering directory `/Users/denisnadey/Desktop/Project/с/Philosophers' -make: Leaving directory `/Users/denisnadey/Desktop/Project/с/Philosophers' +make --dry-run --always-make --keep-going --print-directory +make: Entering directory `/Users/mdenys/Desktop/projects/philosophers' -make: *** No rule to make target `all'. +make: Leaving directory `/Users/mdenys/Desktop/projects/philosophers' + +make: *** No targets specified and no makefile found. Stop. diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b114f30 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug", + "program": "${workspaceFolder}/philo_one/philo_one", + "args": ["5", "1", "1", "1", "1"], + "cwd": "${workspaceFolder}" + } + ] +} diff --git a/.vscode/targets.log b/.vscode/targets.log index 0d230d3..f9b0452 100644 --- a/.vscode/targets.log +++ b/.vscode/targets.log @@ -7,11 +7,8 @@ make all --print-data-base --no-builtin-variables --no-builtin-rules --question # This program built for i386-apple-darwin11.3.0 -make: *** No rule to make target `all'. Stop. - -# Make data base, printed on Sun May 9 12:20:42 2021 - +# Make data base, printed on Wed May 12 17:25:51 2021 # Variables @@ -28,27 +25,30 @@ VSCODE_LOG_NATIVE = false # automatic @F = $(notdir $@) # makefile -CURDIR := /Users/denisnadey/Desktop/Project/с/Philosophers +CURDIR := /Users/mdenys/Desktop/projects/philosophers # makefile SHELL = /bin/sh # environment -VSCODE_NLS_CONFIG = {"locale":"ru","availableLanguages":{},"_languagePackSupport":true} +VSCODE_NLS_CONFIG = {"locale":"en-us","availableLanguages":{},"_languagePackSupport":true} # environment _ = /usr/bin/make # makefile MAKEFILE_LIST := # environment -VSCODE_NODE_CACHED_DATA_DIR = /Users/denisnadey/Library/Application Support/Code/CachedData/cfa2e218100323074ac1948c885448fdf4de2a7f +VSCODE_NODE_CACHED_DATA_DIR = /Users/mdenys/Library/Application Support/Code/CachedData/cfa2e218100323074ac1948c885448fdf4de2a7f # environment VSCODE_VERBOSE_LOGGING = true # environment -__CFBundleIdentifier = com.microsoft.VSCode -# environment -VSCODE_IPC_HOOK_EXTHOST = /var/folders/kq/kc3pf_ns62n6hc7n74119qf00000gn/T/vscode-ipc-d8ce7923-f56f-4eb9-b774-6248ac64f344.sock +VSCODE_IPC_HOOK_EXTHOST = /var/folders/zz/zyxvpxvq6csfxvn_n003vhs000yw68/T/vscode-ipc-5e87255d-4c59-4ce0-938f-d9af1a63e1c5.sock # environment VSCODE_CWD = / # environment -PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/denisnadey/development/flutter/bin:/opt/homebrew/bin +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. + # environment VSCODE_LOG_STACK = false # environment @@ -56,23 +56,25 @@ ELECTRON_RUN_AS_NODE = 1 # default .FEATURES := target-specific order-only second-expansion else-if archives jobserver check-symlink # environment -SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.F5MO7Kk0sJ/Listeners +SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.HmOvHs1Y9f/Listeners # automatic %F = $(notdir $%) # environment +HOMEBREW_TEMP = /tmp/mdenys/Homebrew/Temp +# environment VSCODE_PIPE_LOGGING = true # environment -PWD = /Users/denisnadey/Desktop/Project/с/Philosophers +PWD = /Users/mdenys/Desktop/projects/philosophers # environment ORIGINAL_XDG_CURRENT_DESKTOP = undefined # environment VSCODE_AMD_ENTRYPOINT = vs/workbench/services/extensions/node/extensionHostProcess # environment -HOME = /Users/denisnadey +HOME = /Users/mdenys # default MAKEFILEPATH := /Applications/Xcode.app/Contents/Developer/Makefiles # environment -LOGNAME = denisnadey +LOGNAME = mdenys # environment APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = true # environment @@ -81,31 +83,40 @@ VSCODE_HANDLES_UNCAUGHT_ERRORS = true ^D = $(patsubst %/,%,$(dir $^)) # environment XPC_FLAGS = 0x0 +# environment +COLORTERM = truecolor # default MAKE = $(MAKE_COMMAND) -# default -MAKECMDGOALS := all # environment -SHLVL = 1 +LC_TERMINAL = iTerm2 +# environment +HOMEBREW_CACHE = /tmp/mdenys/Homebrew/Caches +# environment +SHLVL = 2 # default MAKE_VERSION := 3.81 # environment -USER = denisnadey +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 -TMPDIR = /var/folders/kq/kc3pf_ns62n6hc7n74119qf00000gn/T/ +TMPDIR = /var/folders/zz/zyxvpxvq6csfxvn_n003vhs000yw68/T/ # automatic *F = $(notdir $*) # environment -VSCODE_IPC_HOOK = /Users/denisnadey/Library/Application Support/Code/1.56.0-main.sock +VSCODE_IPC_HOOK = /Users/mdenys/Library/Application Support/Code/1.56.0-main.sock # makefile MAKEFLAGS = Rrqp # environment @@ -113,33 +124,45 @@ MFLAGS = -Rrqp # automatic *D = $(patsubst %/,%,$(dir $*)) # environment -XPC_SERVICE_NAME = application.com.microsoft.VSCode.3567092.3567098 +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 -__CF_USER_TEXT_ENCODING = 0x1F5:0x7:0x31 +ITERM_SESSION_ID = w0t0p0:520B77F0-CFEA-4D37-8A86-B45CDD412BEF # environment -COMMAND_MODE = unix2003 +COLORFGBG = 7;0 +# environment +__CF_USER_TEXT_ENCODING = 0xF70C8:0x0:0x0 # default MAKEFILES := # automatic +typedef struct s_philo +{ + int right_fork; + int left_fork; +} t_philo; + typedef struct s_philo_data { pthread_mutex_t *mutex; + t_philo *philors; } t_philo_data; - typedef struct s_all { int number_of_philosophers; diff --git a/philo_one/obj/logic.o b/philo_one/obj/logic.o index cbd161a..a232e7c 100644 Binary files a/philo_one/obj/logic.o and b/philo_one/obj/logic.o differ diff --git a/philo_one/obj/main.o b/philo_one/obj/main.o index 1460cf1..8b007d0 100644 Binary files a/philo_one/obj/main.o and b/philo_one/obj/main.o differ diff --git a/philo_one/obj/parser.o b/philo_one/obj/parser.o index db8d9fe..6d3808a 100644 Binary files a/philo_one/obj/parser.o and b/philo_one/obj/parser.o differ diff --git a/philo_one/obj/utilc.o b/philo_one/obj/utilc.o index 19865c1..1ce62cd 100644 Binary files a/philo_one/obj/utilc.o and b/philo_one/obj/utilc.o differ diff --git a/philo_one/philo_one b/philo_one/philo_one index 23cc77d..6c33ae7 100755 Binary files a/philo_one/philo_one and b/philo_one/philo_one differ diff --git a/philo_one/srcs/logic.c b/philo_one/srcs/logic.c index f257345..d89e44f 100644 --- a/philo_one/srcs/logic.c +++ b/philo_one/srcs/logic.c @@ -34,11 +34,43 @@ int func_test(t_all *all) return (0); } +void get_fork_for_philo(t_all *all) +{ + int i; + + i = 0; + + while(i <= all->number_of_philosophers) + { + if (i == 0) + { + all->data_philo->philors[i].left_fork = all->number_of_philosophers; + all->data_philo->philors[i].right_fork = 0; + } + else + { + all->data_philo->philors[i].left_fork = i; + all->data_philo->philors[i].right_fork = i + 1; + } + i++; + } +} int prepare_resources(t_all *all) { + int i; + + i = 0; all->data_philo = ft_calloc(sizeof(t_philo_data), 1); all->data_philo->mutex = (pthread_mutex_t *)ft_calloc(sizeof(pthread_mutex_t), all->number_of_philosophers); + while (i < all->number_of_philosophers) + { + pthread_mutex_init(&all->data_philo->mutex[i], NULL); + i++; + } + all->data_philo->philors = (t_philo *)ft_calloc(sizeof(t_philo), all->number_of_philosophers); + get_fork_for_philo(all); + return (0); } int runner(t_all *all, int optional) diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 0000000..40fe023 --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "." + } + ] +} \ No newline at end of file