I was about to ask you in telegram if you were already in philosophers, I just started as well. After the FDF project I started to do a really cool thing for the projects, which is to first create a flowchart of how my program is suppose to work, it makes the project so much easy-going, it really helps a lot, if it of you interest I can later share with you my ideas of how I organize my projects now!
I have a question. In the minute 27:26 you say that philosopher 1 and 3 will eat at the same time, but when you open the visualizer 27:44 only the 3 starts to eat i the first round. Why?
Because philo #2 managed to take the fork that is shared with philo #1. Threads work with different speed, thread #1 can stop for a little fraction of a millisecond and thread #2 might be faster. I think this is the reason, may not be true though =)
Hey Jamshidbek, in this explanation you saying that there are three ways to synchronize and to manage the order of the routine for the philosophers, odd sleep first, odd take from right, even take from left. Or all philo's take from right except last one. However, when I'm checking your code. You only implemented even philo's sleep first. Besided that all philo's start with right fork, and they drop left fork first. This works however its giving a lock-inversion warning with threadsanitize. Can you explain why you have only done this implementation? For me the other ones you listed didn't work for me for example ./philo 3 610 200 200 5.
Hello! This is a good question. First I used 2 methods, one for mandatory part (taking forks from different sides) and one for bonus (syncronize by making half of them sleep). But later I found out that first of them was not perfect, in the case of odd number of philos (5 650 200 200), or the example you gave. In theory this case should work, but I noticed that it didn't. It worked only when time_to_die is in this ration 5 800 200 200. When it comes to the 3rd option, when only one philo takes from left and others from right, as I mentioned in the video I didn't use it. I heard some people used it. I didn't face lock-inversion warning. When checking my philos I used valgrind and fsanitize with thread checks. This is what I know, maybe there are better ways =)
@@jamshidbekergashev6746 strange, I'm very stuck to be honest. I tried all the ways, but simulation only works when all philo's start with right fork. And this gives me a lock-inversion warning.
@@Ole_Hendrix Problem can be in anything. Try to run it on linux (maybe docker container). Because Mac's valgrind wasn't working well for me. Otherwise, try to compare what you do differently than I did. My code is more or less clean and should be easy to follow. If your's is also clean, maybe I could spend 5 minutes to take a look. But can't promise to solve the problem.
github.com/Jamshidbek2000
thanks from 42 Quebec!
Waw 👏. that is what we need . Keep doing man . Thanks for help 😉
Hey Jamshidbek! Thanks for the video, helped quite a lot to clarify the path forward! 💪
Hi there! I am glad it helped.
Good luck with implementation 👍
HHey bro! Thx very much!! Why you did only one video, i will recommend everyone on my 42 discord community 🔥 keep it up
Master!
I was about to ask you in telegram if you were already in philosophers, I just started as well. After the FDF project I started to do a really cool thing for the projects, which is to first create a flowchart of how my program is suppose to work, it makes the project so much easy-going, it really helps a lot, if it of you interest I can later share with you my ideas of how I organize my projects now!
Master hhahhah! Sure i am interested! 🔥@@v4r3j4o9
I am glad if I could help) This is my small contribution to 42 community.
Thanks for engagement, appreciate it!
Thank you for your good explanation. ✌🏼
Thank you, it was wonderful.
Nice video! thx a lot from France
Amazing! Good luck with the project
Thanks very much!
My pleasure!
спасибо за объяснение! привет из 42 Мадрид 😊
Привет! Рад помочь =)
I have a question. In the minute 27:26 you say that philosopher 1 and 3 will eat at the same time, but when you open the visualizer 27:44 only the 3 starts to eat i the first round. Why?
Because philo #2 managed to take the fork that is shared with philo #1. Threads work with different speed, thread #1 can stop for a little fraction of a millisecond and thread #2 might be faster. I think this is the reason, may not be true though =)
Thank you very much !)
I'm glad I could help =)
hey thanks a lot! for now everything is clear, but I haven't started coding it😅
👍😅
what a hunk
W
Hey Jamshidbek, in this explanation you saying that there are three ways to synchronize and to manage the order of the routine for the philosophers, odd sleep first, odd take from right, even take from left. Or all philo's take from right except last one.
However, when I'm checking your code. You only implemented even philo's sleep first. Besided that all philo's start with right fork, and they drop left fork first. This works however its giving a lock-inversion warning with threadsanitize.
Can you explain why you have only done this implementation? For me the other ones you listed didn't work for me for example ./philo 3 610 200 200 5.
Hello!
This is a good question. First I used 2 methods, one for mandatory part (taking forks from different sides) and one for bonus (syncronize by making half of them sleep). But later I found out that first of them was not perfect, in the case of odd number of philos (5 650 200 200), or the example you gave.
In theory this case should work, but I noticed that it didn't. It worked only when time_to_die is in this ration 5 800 200 200.
When it comes to the 3rd option, when only one philo takes from left and others from right, as I mentioned in the video I didn't use it. I heard some people used it.
I didn't face lock-inversion warning. When checking my philos I used valgrind and fsanitize with thread checks.
This is what I know, maybe there are better ways =)
@@jamshidbekergashev6746 strange, I'm very stuck to be honest. I tried all the ways, but simulation only works when all philo's start with right fork. And this gives me a lock-inversion warning.
@@Ole_Hendrix Problem can be in anything. Try to run it on linux (maybe docker container). Because Mac's valgrind wasn't working well for me.
Otherwise, try to compare what you do differently than I did. My code is more or less clean and should be easy to follow. If your's is also clean, maybe I could spend 5 minutes to take a look. But can't promise to solve the problem.
👋