Комментарии:
Thread-safe-ness is a really important topic :) amazing explanation - enjoyed it, even though i already knew about it. never seen it in assembly though. loved that part, helps understanding the whole picture if you're not into it.
Ответитьsir one video create on setup phtread in vs code
Ответить@codeVault Hello sir could you justify this statement. If threads run parallely then for the mail variable gets incremented by the two threads at the same time.
So the net increase in the count should be 1. As both the threads increment the mails variable at same time.
Thank you so much!
ОтветитьWow, impressive clear and really fast to understand the concept. Thank you!
ОтветитьIt's also important to note the case when each thread reads the same value from memory, increments it and writes it back to memory, effectively "removing" one of the thread operations. I think this is more likely to happen than one thread being allowed to run multiple times before allowing the next to run and undo the work of the first thread
Ответитьwow, what a lesson, thank you so much
Ответитьthank you very much, it was amazing to see how the assembly do things
Ответить2 words. Thank you.
Ответитьsomething to do with "white privilege" and colonialism?
ОтветитьFirst time getting in contact with threads, you make the concept so easy to understand. Thanks a lot for the content!
ОтветитьWhat if I'm working with threads and I get an unexpected value just like in the mailbox example. How can I tell if the result is due to a race condition or to an overflow ?
ОтветитьYou need to make that global variable volatile and make sure your compiler doesn't optimize your loop.
ОтветитьDude, this is great stuff! Excellent explanation skills
ОтветитьCan I say race condition is more likely to occur when setting loop to 1 million because it takes longer time to finish the execution for each threads? In other words, thread p2 will be created after thread p1. But it is up to OS scheduler to decide which thread to run and how long it will run for one scheduling time slot. So if the execution time is very long and need more than just one scheduling slots, it is much easier to threads to interleave with each other. Is my understanding correct? Anyway, thanks for your great explanation in the video!
ОтветитьThose from 42 Network, give it a like and good luck with the philosophers project! 🙏
ОтветитьGreat video! Thanks for the great explanation. I mainly use Python but this was very similar
ОтветитьWhy didn’t we created separate routine for both the threads and added a sleep in one thread to simulate one thread occupied while other is executing longer
Agree that race condition is not guaranteed but the probability will increase right?
You should be extremely proud of yourself. You explained it beautifully.
ОтветитьHey,
First thing thank you very much for your Videos, could you name the IDE, which do you use ? and on which Operating system do you work ?
Ich hope of an answer :)
Stunning explanation!
ОтветитьNever seen race conditions broken down pragmatically like this in my life. I was awestruck when you took it to the assembly level. I couldn't believe my eyes. Thanks for this great video boss.
ОтветитьYou are Genius, i am cannot speak english very well but i want to say to you very very very thank you about this amazing explanation
ОтветитьThank you! clearly explained
Ответитьit is a mass defect (nuclear mass) :)
ОтветитьThank you very much for all of your videos about processes and threads
ОтветитьThank you a lot for the video! Great as always :) Could you please explain why there is the same number (23) at "read mails" and "increment" steps? I assumed the incrementation step result is 24 as well as the "write" step
Ответитьunderstood
ОтветитьI get so happy when I search up an OS topic and your video pops up because I know for a fact Ill understand it. Amazing work man!!
Ответитьaccording to your code there are 2 pthreads, with small numbers in mail variable increment both the thread excecuted sequentially (first thread 1 and after that thread 2). when you increased mail increment to 1000000 does thread one and thread 2 excecutes concurrently ? if they excecute concurrently, will this concurrent excecution will occur on single core cpu's ? or this concurrent excucution will happen only on cpu's with dual or more cores ? anyone please explain
ОтветитьA 100 iterations didnt work because C compiler optimization turns loops where there is only one number incremented a couple times into "non loops", so a loop where x is inc. 10 times will be turned into x += 10 by the compiler. Thats why there were no race conditions with small numbers. Not because it takes too long or too short or smth ... .This optimisation stops at a certain number.
ОтветитьFantastic video totally understand now
ОтветитьIt occurs to me race conditions could be used to generate truly random numbers, something like:
void* rng_thread( void *ud )
{
while ( 1 )
{
rng_seed++;
pthread_yield();
}
}
The pthread_yield() is just there to give the system a chance to kill the app &/or thread
Dude, you could give a simpler to understand explanation for noobs:
Think of each thread as a person, they each copy information from a document, they then modify that information and overwrite the old information, each person starts at different times but over time their timings align such that when one person copies information it is before the other person has updated the information with their own modified state meaning the information they modify is out of date and will cause the other person to get older information after they overwrite the documents information, the timing of the overwrites is the race condition
Doing Wonderful Job ...that to for free. Service to humanity, sure you will be suitably rewarded.
ОтветитьAhahhaha he's so funny! It's charming to watch your videos. You have a very awesome vibe!
ОтветитьYou explain soooo well
Ответитьif professors could explain like you everyone would pass
ОтветитьHow did you open assembly page? I can't open it.
Ответитьbut the pthread_exit() is important ? or not?
ОтветитьOutstanding explanation mate
Ответитьas i heard from you that with threading that threads should go in parallel, as you show in a previous video example. Isnt race condition breaking the parallel thing here? very nice explanation
ОтветитьVery clear explanation and a great course in total!
ОтветитьAwesome stuff! One thing I don't get is how each thread's register would hold on to the value it originally read in a single CPU. If both threads are run on separate CPUs then it makes sense, but if they are both on the same CPU then surely the other thread will overwrite eax with its own value unless there are additional instructions to push the original value to another register or to memory to save it? Does the kernel do this automatically when it tells the thread to 'take a break'? :)
ОтветитьAs somebody who is just at the beginner level of C I can say, you produce the most "family friendly" (all the "horrors" of C compiled into nice, easy to follow explanations) videos on C. Well done!
ОтветитьThe OS subject should be taught like this, instead of whiteboarding.
This is to the point. Thanks!