Source code can be found here: code-vault.net... ===== Support us through our store ===== code-vault.net... ===== Check out our website ===== code-vault.net ===== Check out our Discord server ===== discord.code-v...
Пікірлер: 211
@sergiomontes86063 жыл бұрын
This man deserves so many more views and subscribers. So well explained. My professors need to learn from him on how to teach.
@Alexander_444.203 жыл бұрын
yup
@habilel50563 жыл бұрын
i reply for the referencement
@sammyxf69922 жыл бұрын
Exactly
@잠만보-k7s3 жыл бұрын
This man is practically the best teacher I've ever had. Thank you SOOO MUCH.
@SleepinKnight24 күн бұрын
Give a man a fish and he'll eat for a day. Teach a man to fish and he'll eat every day. You are outstanding teacher mate. Your approach to keep these amazing videos free of cost makes you great!!! Amazing!!!!
@shanthgaitonde2 жыл бұрын
The operations performed by a thread after acquiring a lock are called "critical section". This helps in achieving thread synchronisation. Thanks for the video!
@sagejpc1175 Жыл бұрын
I want you to know you have taught me more about the C language in 10 minutes than an entire university lecture did in 80 minutes. I need to learn this for a project and you have made my life so much easier. Thank you so much.
@wtfitsdrewbritton2 жыл бұрын
Can’t thank you enough for your detailed and succinct explanations! When I began diving in to multithreaded programming with C++17 I became overwhelmed pretty quickly
@akapotatis94453 жыл бұрын
This is something random but it's so attractive seeing someone being so smart
@CodeVault3 жыл бұрын
Thanks haha
@zakwanashfaq98793 жыл бұрын
you should train professors on how to teach Thanks for explaining, it was very easy to understand.
@bh3302 Жыл бұрын
Man, you are an absolute legend! Thank you so much for uploading this.
@triplestrikee8752 жыл бұрын
The lock variable + if block example is the best example I have even seen for this Mutex topic
@harshmishra9941 Жыл бұрын
I purely watched this playlist to understand what the heck my OS prof was teaching when she taught us semaphores (although for processes) and I couldn't understand at that time. Loved it !
@PHTM0410 ай бұрын
Subscribed to your channel man. Its crazy how you break down everything into making them seem so easy! Much appreciated dude and I really hope more see your channel, much love!
@thegameisneverover75583 жыл бұрын
BRO your tutorials bring me through my whole semester
@ditobrando440711 ай бұрын
I wish you were one of my professors. Every time I watch a video from you I get excited to code again.
@giladefrati84148 ай бұрын
Thank you very much! You explained it so well and clearly; when my university lecturer explained it to me, I did not understand anything. I really like your channel.
@havoc14172 жыл бұрын
Man, you really make C look very simple and lovable.
@cicerotcv3 жыл бұрын
I bet you are not even close to understand how good you've done for humanity since you started this channel. Thank you very much.
@timse6992 жыл бұрын
This man is practically the best teacher! Sub!
@ryanc674 Жыл бұрын
dude you’re the best. Thank you so much for making these videos
@imqwerty51713 жыл бұрын
Thanks for making these amazing tutorials. You earned a sub
@arushi78993 жыл бұрын
You're an AMAZING teacher, Sir. Thanks for this. Subscribed!
@morefun790 Жыл бұрын
You make complex things more easier, great job !! thank you.
@relicdelic8333 жыл бұрын
Hello. This is one of the greatest tutorials I've seen. I will be watching the whole playlist, thank you for your hard work and skill in education.
@FrodosBeutel3 жыл бұрын
You saved alot of work and misunderstanding with the threads videos. Thanks alot
@DeezNardsX22 күн бұрын
Just a slight correction at the end: You can have race conditions on single core processors. We can fake "parallel execution" by time slicing. If the two threads are sharing memory resources, then we can absolutely have a race condition during a context switch.
@CodeVault20 күн бұрын
That is correct.
@ManaswiRaj-p8u8 ай бұрын
Race conditions can also occur on single core processors like if we consider concurrent CPU and the operations are read, increment and write. So lets say P1 starts first then P1 reads increments and then it is preempted by another process P2, then P2 does read, increment and then it is preempted by P1. Now P1 writes the value and exits after which P2 comes and writes its value thus there is a race condition
@CodeVault7 ай бұрын
You're right, I didn't want to go into much detail regarding this and gave a simple (albeit wrong) explanation
@spexon73113 жыл бұрын
You can tell how helpful his videos are because I have not seen 1 dislike yet. You make this so understandable
@ndf7828 ай бұрын
Your classes are amazing! All of them! Just one thing, I think that when you say race condition, the correct term is data race. Cheers!
@Codality2 жыл бұрын
thank you really , you are better than almost all the teachers in this world... all the respect
@AdiSings2023 Жыл бұрын
Best course on Multithreading!!
@0xfsaymyname6 ай бұрын
Man you are a God, thanks to sharing this with us!
@sharifsircar3 жыл бұрын
I'd be screwed if it wasn't for many of your c videos
@Dogdrulezz2 жыл бұрын
This man is amazing! I wish he had merch, I would love to rock a code vault T-Shirt or Hoody
@CodeVault Жыл бұрын
Haha, thanks. I will think about launching some merch if enough people want them
@satvikkhare18442 жыл бұрын
Thank you sir, these tutorials have made my synchronisation concepts very clear.
@sanguinho Жыл бұрын
What a clear and simple explanation. Thanks my dude
@iloveukraine-subscribe1kgo8223 жыл бұрын
Thank you for the practical Mutual Exclusion video.
@msimamsima90592 жыл бұрын
Mutual Exception.
@barankaplan43083 жыл бұрын
PERFECT! looking forward to see a video about spinlock!
@Achao3_AkaoShiro_3 жыл бұрын
Great video, explained how lock and unlock work really well. I was having trouble understanding what it was with my professors explanation lol. Thanks for explaining it, you definitely deserve more views and subs!
@yernarduisebai56092 жыл бұрын
You explain way more clear than my professor Park
@izharhussain72413 жыл бұрын
you are a gem! Thank you for the videos.
@ayoubrayanemesbah8845 Жыл бұрын
just a note mutuale exclusion problem can heppen even for single core processors , because when the quantum ends of a processoes , another process can modifie the variable
@AshishSinghh2 жыл бұрын
You are a gem 🙏🏻
@dudidaabul17823 жыл бұрын
Great job. Explanations are easy and clear, very useful information. Thanks a lot!!!
@dobariyavraj3659 Жыл бұрын
God send savior, HE's the ONE
@tiemen882 жыл бұрын
Thank you so much for the explanation on Pthread mutex!
@alireza983252 жыл бұрын
Great tutorial. I have one comment about the likelihood of race condition happening for single-core processors. Even with a single core and a single processor but multiple threads (as it is the case for the FreeRTOS OS in embedded systems), race conditions will happen more often than not without a mutex, atomic instructions, etc.
@CodeVault2 жыл бұрын
Thanks! Interesting. I wonder now about single-core single-thread environments. Technically there still should be some race conditions but they might be encountered less often. Would you like to test that?
@alireza983252 жыл бұрын
@@CodeVault I think the only possibility for race conditions to happen for single-core single-threaded app, is when a hardware interrupt occurs and ISR gets executed. If hardware interrupts were not present, I'm not sure race conditions can ever occur for a single-core, single-threaded app
@Nat-qm5vb Жыл бұрын
Once again, KZbin saves my homework. Thank you!
@ruxandrawoinaroski56904 ай бұрын
Foarte bine explicat, mersi :)
@LinusKarlssonMusic2 жыл бұрын
Thanks for the great explanation!
@ivanleon6164 Жыл бұрын
race cond can also happen in single core if interrupts are enabledand a variable is modified.
@bacnguyenkhac1542 жыл бұрын
many thanks for this series, sir! you'v saved me !!!!
@galkk33 жыл бұрын
I really enjoy your videos, thank you Could you make a video about Condition Variables with threads?
@CodeVault3 жыл бұрын
Will do
@log_of_12 жыл бұрын
Really a wonderful explanation. Thank you!
@patrykjaworski4024 жыл бұрын
I love your videos. Your materials are helping me a lot more than my lecturers do and also you making it simple and more understable. Looking forward to POSIX/ SYS V semaphores. Also I would like to ask will there be coming more materials about pthreads ? ( maybe private data of threads). Best of regards code vault. Keep it up!
@CodeVault4 жыл бұрын
Thank you! And yes, the last lessons in the course are not yet decided so will add most of the suggestion from the community there (like this one ;) ).
@matthewjiang94503 жыл бұрын
Fantastic explanation!!! Thanks
@tahmeerimtiaz31233 жыл бұрын
Thanks you so much you teaching method are soooo good.
@armandomiguelzegarracastil21343 жыл бұрын
AMAZING TEACHER!!!!!!!!!!!!!!!!!! THANK YOU!!!
@giuliamarceladesenafaria3170 Жыл бұрын
thank you for this playlist
@abugslife24613 жыл бұрын
This is beyond helpful! Thank you so much :)
@pagetwnas13 жыл бұрын
Thank you sir , I appreciate your help !
@javiercardoso5669 Жыл бұрын
Thank you so much for the video!
@jong.48642 жыл бұрын
Thank you, you're so helpful!
@msimamsima90592 жыл бұрын
Very useful video! Thank you!
4 жыл бұрын
Could you make a video about semaphores and pointing the differences between it and mutexes' use cases?
@CodeVault4 жыл бұрын
Yep, semaphores and barriers are also planned for this course
@dorianalary78492 жыл бұрын
Its incredible, I'm French but I understood perfectly this video, thanks you
@AsliArtistVlogs2 жыл бұрын
Race codnitions can very well occur in single core processors too. Think of pre-emption.
@timonburkard34812 жыл бұрын
Exactly.
@alihantasyurek433811 ай бұрын
Ty for the awesome videos!
@cindaellas4 ай бұрын
great video! thanks!!!! very good job! greetings from germany
@chaimaeelhaimer8703 жыл бұрын
Bravo ! thanks for explaining my question is : when we may need to create 2 threads with same function?
@CodeVault3 жыл бұрын
Whenever you want to split CPU intensive work between the threads, that's when the workload is exactly the same except for some indices.
@Dave-cq6pu4 жыл бұрын
Really useful videos, just as im learning this at school :D
@Smile-si8xv7 ай бұрын
arrayyy u r great ji😍
@Jonathan-ru9zl11 ай бұрын
amazing explanation.
@Alexander_444.203 жыл бұрын
great explanation thank you!
@Brad_Script5 ай бұрын
Apparently there's another way of initializing a pthread_mutex: pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; I wonder what the difference is
@CodeVault2 ай бұрын
They are basically the same. The first one could technically be faster since it only assigns some values but can only be used. Also, it guarantees that the lock is always initialized
@viniciuss.92502 жыл бұрын
Thank you SOOO MUCH.
@narasarajv52784 жыл бұрын
Real time example super explanation.
@peerapatratanachartchuchai58442 жыл бұрын
Thank you for your great video bro. You save my life !!! Just curious a little bit from the last video. Base on my understanding, Race condition happen when 2 thread read memory at the same time. Is that possible if mutex lock data in exactly same time and race condition happen. If not why?
@CodeVault2 жыл бұрын
First things first: a race condition happens only in two cases: 1) You have one thread writing a piece of data while other threads are reading it 2) You have multiple threads writing the same piece of data Two threads reading the same piece of data won't cause a race condition. Although with mutexes a read and write could happen at the same time, they are designed so that each read and write on them is atomic, meaning there's no way other threads could read the data while another is in the process of writing it (only before it wrote to it or after that)
@austinoquinn815 Жыл бұрын
Maybe a minor misstatement when you say race conditions only happen on multicore systems. I think race conditions can also happen on one core processors. You could save your mails in thread 1 context switch to thread 2 and finish loop then go back to 1 and finish, then your result would only be 1,000,000 on write back. Great content though. Love this playlist.
@CodeVault Жыл бұрын
Yes, it's definitely wrong. Race conditions can happen on any system. It's just much much rare to happen on single-core processors as the context switch would have to happen right between an assignment (which, from what I recall, is a very low chance). Maybe I will make a video on this topic to investigate what is the chance of that happening and whatnot
@austinoquinn815 Жыл бұрын
@@CodeVault that would be awesome 👍🏻
@soumavadas1400 Жыл бұрын
Love your Videos
@neeluiiitd Жыл бұрын
Thank you.
@misterSaragi3 жыл бұрын
Your a gem!
@johnthompson4011 Жыл бұрын
Bro small problem with your code.I took this as a refresher to threads.Locking and unlocking the mutex in each iteration of the loop introduces unnecessary overhead and reduces the potential benefits of multithreading. A better way is to lock and unlock it outside the loop.Anyway thanks for the video bro
@CodeVault Жыл бұрын
Of course. But this was a short explanation and I wanted to show that the mutexes work even if multiple loops are executing at the same time. In a production environment, this would be very inefficient indeed
@sakkamouid3343 Жыл бұрын
I think using lock the execution of the program would be slower, but that is not important . More important is avoiding race condition
@wisiw Жыл бұрын
Yes but doesn't that mean we're forcing multithreading program into serial program?
@anthonymarcovecchio5201 Жыл бұрын
Good stuff my friend
@dattakunal Жыл бұрын
Thanks for the wonderful video. I have a question. What happens if thread 1 throws an error before the unlock? Will thread 2 wait forever?
@CodeVault Жыл бұрын
The lock is released, so thread 2 won't wait forever
@oguzhanasilturk5110 Жыл бұрын
man, i wanna be your thread. such a good explanation
@solomonpierce2676 Жыл бұрын
good explanation!
@IDsirbu3 жыл бұрын
Great work
@fernandaeschallots24853 жыл бұрын
Your video is the best. thx
@Edvs32614 жыл бұрын
Could you please make a video about marge, selection, bubble and quick sort in c?
@CodeVault4 жыл бұрын
Will look into it... may come at a later time tho
@Edvs32614 жыл бұрын
@@CodeVault thanks!
@habilel50563 жыл бұрын
i comment for the referencement, you're a good guy
@mikicerise62503 жыл бұрын
Thank you! :)
@Hammy_Pig3 жыл бұрын
you are a god
@oshadhaedirisinghe14558 ай бұрын
Thank you
@coolboy321513 жыл бұрын
very underrated
@kamurashev Жыл бұрын
I believe it’d be fair to at least mention that there are other options to approach this. Eg in this example atomic would work better.
@CodeVault Жыл бұрын
You mean atomic operations?
@kamurashev Жыл бұрын
@@CodeVault yep, like using atomic_int eg
@spellignerror899811 ай бұрын
2:09 what if the threads met a race condition at reading lock?
@CodeVault10 ай бұрын
locks are thread-safe at the OS level
@wisiw Жыл бұрын
Can we say that mutex locking forces the multithreading routine into serial?
@CodeVault Жыл бұрын
Yes. Basically the critical section that is surrounded by a mutex lock/unlock will always be serially executed
@DineshKumar-wo4tj2 жыл бұрын
Even if I comment mutex_init and mutex_destroy, i can able to see mutex lock/unlock is working. Then what is the use of init/destroy function???
@CodeVault2 жыл бұрын
Well, init is surely needed when using a mutex. Although, probably, since the mutex is global in this video it gets its members automatically initialized to 0 and I think that coincides with what pthread_mutex_init sets the values to. If you try to use the a local mutex I think you'd have issues without the init function call. The pthread_mutex_destroy is not 100% necessary on some architectures but it's good practice
@DineshKumar-wo4tj2 жыл бұрын
@@CodeVault Thank you for your clarity.
@selvamthiagarajan81529 ай бұрын
say in the routine() function I had 3 different operations, op1, op2, op3. I place a mutex_lock before op1, mutex_unlock after op1. Assume 3 threads. Will the other threads execute op2, and op3 when op1 is under lock ?
@CodeVault7 ай бұрын
No, they won't. All threads will wait at the mutex_lock instruction until the lock is unlocked. Though, this still allows for race conditions on op2 and op3