Condition variables in C

  Рет қаралды 93,096

CodeVault

CodeVault

Күн бұрын

Source code can be found here:
code-vault.net/lesson/18ec194...
===== Support us through our store =====
code-vault.net/shop
===== Check out our website =====
code-vault.net
===== Check out our Discord server =====
discord.code-vault.net

Пікірлер: 179
@CARDSSerus
@CARDSSerus 3 жыл бұрын
I'm sure this gets said a lot, but this pthread playlist has legitimately helped me more than a semester of class. Thank you
@mba2ceo
@mba2ceo 9 ай бұрын
most PORFESSIONOR ARE INEPT IDIOTS
@ArkFreestyle
@ArkFreestyle 3 жыл бұрын
Thank you so much, these are the highest quality C tutorials on youtube. Very underrated channel, you're an excellent teacher, please continue teaching!
@trevorjoel2150
@trevorjoel2150 2 жыл бұрын
I dont mean to be offtopic but does someone know of a method to get back into an Instagram account? I was dumb lost my password. I appreciate any help you can offer me!
@samuellionel4364
@samuellionel4364 2 жыл бұрын
@Trevor Joel instablaster :)
@trevorjoel2150
@trevorjoel2150 2 жыл бұрын
@Samuel Lionel Thanks for your reply. I found the site through google and I'm waiting for the hacking stuff atm. Looks like it's gonna take a while so I will get back to you later with my results.
@benjangel
@benjangel 2 ай бұрын
I cannot describe my gratitude my man. Solid high quality teaching. You're being loved from Turkiye.
@mustafakarakas1116
@mustafakarakas1116 2 жыл бұрын
16:35 The difference between pthread_cond_signal() and pthread_cond_broadcast() lies in what happens if multiple threads are blocked in pthread_cond_wait(). With pthread_cond_signal(), we are simply guaranteed that at least one of the blocked threads is woken up; with pthread_cond_broadcast(), all blocked threads are woken up.
@elenakalla
@elenakalla 3 жыл бұрын
I think you have the best teaching skills I've seen in all my school and University years. Thanks for educating us!
@karangupta431
@karangupta431 3 жыл бұрын
My college teachers should teach like you , our lives would be fantastic then
@tas9214
@tas9214 2 жыл бұрын
Really glad I found this channel, the examples are always on point and a concept that seemed abstract previously makes perfect sense now!
@davidglass4876
@davidglass4876 2 жыл бұрын
Wow well done! You did an amazing job explaining that. I love how you fast forwarded the more tedious coding we're already familiar with and really took your time with the nuances of condition variables
@tungbigbang98
@tungbigbang98 2 жыл бұрын
You're amazing thank you so much man. Your videos helped me tremendously with our OS and networking classes. Don't stop!
@brianstorm831
@brianstorm831 2 жыл бұрын
Thank you so much for these. You have no idea how much you have helped me with these C videos. God bless you.
@sirnosedevoid2282
@sirnosedevoid2282 3 жыл бұрын
This cleared up so much for me. Thank you very much for posting this!
@asinegaasinega
@asinegaasinega 3 жыл бұрын
this is so so so good. usually, guys are speaking way fast because they don't understand that it's hard to follow the concepts for someone brand new being exposed to the subject. you really have a gift for teaching. People think just because they know a subject matter that they can become teachers but that's is not true. It takes special skills to be able to relate a material to someone else that is brand new to the matter at hand. Just a million thanks
@playertwo9895
@playertwo9895 3 жыл бұрын
Sergiu, I can't thank you enough for this video. My OS professor really struggled to explain this topic, so I left the class without any intuition as to why condition variables were needed. Your example at 8:16 made my jaw drop, furthermore, your description of signalling being an indication that a condition's result *may* have changed really cleared things up for me. This is the second video of yours that I've watched (the first being pthread Barriers). It's safe to say that I'll be subscribing to your channel. Thank you for sharing your knowledge of these complex topics, you make them much easier to understand, and for that I'm grateful.
@playertwo9895
@playertwo9895 Жыл бұрын
I was looking at concurrency stuff again earlier today and remembered this video. Just wanted to say thanks again, I've since graduated and have been working at a big tech company :)
@dakotahrivers6640
@dakotahrivers6640 Жыл бұрын
got your videos opened in one window and VS in another window working my CS 344 final assignment. My guy, you're the reason i'm passing.
@ilusionem2347
@ilusionem2347 10 ай бұрын
best thread playlist s the best I could found in KZfaq! Thanks !!
@mya23compu
@mya23compu 11 ай бұрын
You have successfully explained something that my professors, articles online, a textbook, and documentation couldn't explain well. And concisely too! These videos are amazing, please make more!
@akiraigarashi2874
@akiraigarashi2874 2 жыл бұрын
Thanks a lot for explaining with an example. It really made it a lot easier to understand it's use and how to use it.
@omardumet120
@omardumet120 2 жыл бұрын
thank you so much for your videos, they're amazing!
@abdulrahmansafwat1555
@abdulrahmansafwat1555 8 ай бұрын
Thank You! I have been struggling with this whole concept and then found your video! Well explained! :)
@GeistPatrick
@GeistPatrick 3 жыл бұрын
Just great explanation! Can't wait till I got some time to watch your other content. :)
@utkuerdogan6551
@utkuerdogan6551 3 жыл бұрын
Perfect! . Thank you for sharing your experiences.
@eduardoestevakremer712
@eduardoestevakremer712 3 жыл бұрын
Thanks for this video. Your conceptual explanation is crystal clear !!
@chriscosta8806
@chriscosta8806 3 жыл бұрын
I have been searching since yesterday on condition variables so i can understand what they are exactly and how they work, and i can say it's the most helpful thing! Cheers from Cyprus keep on the good work.
@BankruptGreek
@BankruptGreek 3 жыл бұрын
lmao I am also from Cyprus are you studying on ucy?
@priyankadhiman5384
@priyankadhiman5384 3 жыл бұрын
Thank you. You explained such a complex topic with so much ease. Thanks a lot.
@mohnish.deshpande
@mohnish.deshpande 11 ай бұрын
Thank you so much for this content! Absolutely helpful.
@lin1450
@lin1450 3 жыл бұрын
Dude, you're amazing! Thank you so much!
@onlyfootball6609
@onlyfootball6609 Жыл бұрын
The best video on this topic, best wishes for you!
@onursimsek6094
@onursimsek6094 3 жыл бұрын
Excellent example, excellent content. Thank you.
@martinparidon9056
@martinparidon9056 Ай бұрын
Thank you for this video. It was presented very cleary and understandably.
@AndreFerreira-jv3qy
@AndreFerreira-jv3qy Ай бұрын
Great video man im learning so much from you thank you!
@marcusaurelius6607
@marcusaurelius6607 2 жыл бұрын
Brilliant and simple explanation, helped me to untangle my c++ condvars understanding. Many thanks!
@IamBlueSpirit
@IamBlueSpirit 3 жыл бұрын
Te la rifas mi estimado :33. Muchas gracias por tus videos, me estan ayudando mucho :'3
@leodriesch
@leodriesch 3 жыл бұрын
Great example and great explanation. Thanks!
@williammatiz9745
@williammatiz9745 2 жыл бұрын
Thank you so much for your explanation! It helped a lot.
@bilalbayrakdar7100
@bilalbayrakdar7100 3 жыл бұрын
clear explanation with simple example, thank you for creating such helpful content
@alejandroglez769
@alejandroglez769 2 жыл бұрын
Thank you very much for these videos, you have helped me a lot.
@mey1823
@mey1823 Жыл бұрын
Great explanation! Keep up the good work!
@legonerd162
@legonerd162 2 жыл бұрын
Thank you, this was the only good explanation of condition variables i could find. Very well explained
@taqueritovaquerito
@taqueritovaquerito 2 жыл бұрын
Man I really appreciate the help, you really know how to help
@pascals5408
@pascals5408 3 жыл бұрын
Thanks a lot. It is hard to find people that understand stuff and can explain it properly to others
@1guobro
@1guobro 2 жыл бұрын
Great video, helped me understand CV's from my OS course.
@trocandobytes
@trocandobytes Жыл бұрын
You're amazing. Thank you so much for share this knowledge.
@aMulliganStew
@aMulliganStew Жыл бұрын
15:37 Thanks you for telling us about the implicit unlock and relock.
@javierdiaz1644
@javierdiaz1644 3 жыл бұрын
Best video ever. Keep up the good work man
@oliviachavigny
@oliviachavigny Жыл бұрын
What a good explanation. Thank you!
@SandwichMan
@SandwichMan 3 жыл бұрын
Got a final in 2 days and this was an aspect of synchronization which has been confusing me all semester. Very helpful.
@ubbe9263
@ubbe9263 6 ай бұрын
Great video! Thanks!
@happycode4478
@happycode4478 3 жыл бұрын
Thank you!! Great help for my operating systems class
@matteopisati9966
@matteopisati9966 2 жыл бұрын
Thank you great job!
@guillaume6373
@guillaume6373 2 жыл бұрын
Great explanation!
@timjack5312
@timjack5312 Жыл бұрын
It is good for us to learn the concepts and implementation of the linux c!! Thank you!!
@MyLifeMyWorld08
@MyLifeMyWorld08 2 жыл бұрын
Awesome explanation ! Thanks
@egeergul3548
@egeergul3548 Жыл бұрын
thank you !! Great example!! Helpfull very helpfulllll
@Toccobass13
@Toccobass13 2 жыл бұрын
So helpful, thank you
@milee105
@milee105 9 ай бұрын
very helpful, thank you very much :D
@jiaqimike7114
@jiaqimike7114 2 жыл бұрын
Thank you, it is usefully for my collage work.
@yixianwang863
@yixianwang863 2 жыл бұрын
Thank you!
@Bladermishal10
@Bladermishal10 3 жыл бұрын
Big brain explaination. thank you
@algoeagle7096
@algoeagle7096 2 жыл бұрын
Very well done thank you !
@leonardomaia7661
@leonardomaia7661 2 жыл бұрын
Thank you!! you did what my teacher couldn't
@elizavetaterente2127
@elizavetaterente2127 2 жыл бұрын
Thank you so much omg
@fussball48
@fussball48 3 жыл бұрын
Thank you, I hope it will help my in my exam tomorrow, I will let you know
@fussball48
@fussball48 3 жыл бұрын
I passed, wonderful explanations, thank you
@rhodesiaFarmer
@rhodesiaFarmer Жыл бұрын
Awesome explanation
@deepikadeepika5169
@deepikadeepika5169 2 жыл бұрын
Very helpful !
@narasarajv5278
@narasarajv5278 3 жыл бұрын
Nice explanation Thank you...
@frnz1s
@frnz1s 3 жыл бұрын
Genius teaching!
@kotravaijm250
@kotravaijm250 2 жыл бұрын
you are a life saver
@ArvindDevaraj1
@ArvindDevaraj1 11 ай бұрын
amazing explanation
@karinanosenko4907
@karinanosenko4907 2 жыл бұрын
Great tutorial
@indrajeetdevre1296
@indrajeetdevre1296 Жыл бұрын
THank you
@anamikakumari4311
@anamikakumari4311 2 жыл бұрын
You are the life changer
@sivaramboina9089
@sivaramboina9089 2 жыл бұрын
Pthreads concepts from 0 to master level. Please continue your contributions to this world. __/\__
@elkhoukhi
@elkhoukhi 3 жыл бұрын
You are an awesome teacher! keep on these tutorials coming :)) a question: is this the concept of producer/consumer? as I understand in this case, producer is the fuelFilling and the consumer is the car, right?
@CodeVault
@CodeVault 3 жыл бұрын
I guess you can say that. Usually it has to do with entities in the sense that producers create entities that consumers have to process. Here you only have a number. Here's the video on the producer/consumer problem: code-vault.net/lesson/tlu0jq32v9:1609364042686
@planetis-m6066
@planetis-m6066 3 жыл бұрын
Great video, thank you for sharing! I think it's better to unlock the mutex after signaling the condition variable. Again many thanks!
@CodeVault
@CodeVault 3 жыл бұрын
I was actually curious on that topic and researched a bit. As it turns out, it doesn't really matter. You'd think that, because of the multithreaded nature of the program, there's a chance another thread would lock the mutex right after the unlock and right before the lock inside pthread_cond_wait. While it can happen, that's why we do a check every time we get past the pthread_cond_wait. Additionally, even if we have the order reversed (first signal then unlock), there's a chance another thread locks the mutex right after we call pthread_cond_signal. So either way, you can run in the same issue. Maybe you have another reason for it that I overlooked
@zeobora
@zeobora Жыл бұрын
I'll only say just one word: Perfect!
@amrhesham2260
@amrhesham2260 3 жыл бұрын
thank you, keep going
@saitcanbaskol9897
@saitcanbaskol9897 2 жыл бұрын
Amazing.
@rentka6846
@rentka6846 3 жыл бұрын
these are giving me really good foundational knowledge to carry over to my OS class assignments thank you so much man
@DeathRacerSH97
@DeathRacerSH97 3 жыл бұрын
Plain and simple explaning, great job! Also i like the typing sound, can you share what keyboard and switches you use? Thanks
@CodeVault
@CodeVault 3 жыл бұрын
Thanks! It's a Corsair K63 with Cherry MX reds. Although I don't recommend it, the key caps break very easily.
@mehdicharife2335
@mehdicharife2335 3 жыл бұрын
Great content bro. You must be very smart to be able to come up with these great examples. Do you know where I can find some problems to practice this?
@CodeVault
@CodeVault 3 жыл бұрын
I don't have a special website. But it's easy to come up with one. Just think about a "resource" that can be "used" by many and can be replenished by many others. That's basically it.
@atTran-xv5iz
@atTran-xv5iz 11 ай бұрын
I really hope you will make a similar series with Go
@CodeVault
@CodeVault 11 ай бұрын
The more I look into Go the more interesting it is. I might start learning it and then make some videos about it in the future
@alejandrovesga7736
@alejandrovesga7736 Жыл бұрын
I frickin love u
@basitsaeed9705
@basitsaeed9705 3 жыл бұрын
very helpful
@karangupta431
@karangupta431 3 жыл бұрын
nice explanation
@SebastianPerez-jz9tk
@SebastianPerez-jz9tk Жыл бұрын
So good
@priyeshtandel2101
@priyeshtandel2101 Жыл бұрын
what an example !!🙂
@tinewildiers4618
@tinewildiers4618 3 жыл бұрын
when will the second part of this video be up? great explanation
@CodeVault
@CodeVault 3 жыл бұрын
It's already up ;) You can check it out on our website: code-vault.net/lesson/18ec1942c2da46840693efe9b5203fac I don't usually name things "part 2" so that others searching for this topic will still find that video useful.
@tinewildiers4618
@tinewildiers4618 3 жыл бұрын
@@CodeVault thanks alot
@rivermoon6159
@rivermoon6159 Жыл бұрын
thanks very much. Really saves my ass
@kaal_bhairav_23
@kaal_bhairav_23 3 жыл бұрын
you're the best
@GAMEVUEG
@GAMEVUEG 3 жыл бұрын
I love you bro, are you a teacher ? You are explaining this better than mine
@CodeVault
@CodeVault 3 жыл бұрын
No, I don't teach at any university or school. I just learned by helping a lot of people throughout the years
@saularaya2066
@saularaya2066 Ай бұрын
Piola👍
@user-qo7jv1uk8n
@user-qo7jv1uk8n 2 жыл бұрын
The best tracher i ever have..
@mukundachlerkar8021
@mukundachlerkar8021 3 жыл бұрын
Nice perception.
@mikicerise6250
@mikicerise6250 3 жыл бұрын
I 'cond' wait to start practising with pthread_cond. I'll be here all week folks. ;)
@jacobov3890
@jacobov3890 3 жыл бұрын
Better quality than my university classes. -__-
@sagivalia5041
@sagivalia5041 2 жыл бұрын
Is it possible to pass an array of function pointers, kinda like this thread is doing this series of jobs or before joining pass it another function? EDIT: I tried passing a struct thread_jobs with the job count and a pointer to a function pointer and initialized the struct with an array of function pointers made on the stack of main, passed the struct as an argument and it successfully serialized a series of jobs for each thread. ofc, the function pointer's return type and args are static but as a POC it works.
@nachumdanzig
@nachumdanzig 2 жыл бұрын
Great Instructional Videos. Very helpful. Question: Could you have also solved the problem by putting the Mutex lock AFTER you check that fuel is above 40? Then the car would not lock the mutex unless there was enough fuel. With one car this would work.
@CodeVault
@CodeVault Жыл бұрын
No. That would cause a race condition on the fuel variable. You have to lock the mutex before checking simply because some threads might try to write to that fuel variable in the meantime. So, you must make sure, no other threads are currently trying to write to it.
@blackplaydoh3522
@blackplaydoh3522 3 жыл бұрын
Classic consumer - producer problem, I would much rather see you solve it as an endless simulation (constantly fueling cars and when fuel too low in the main tank -> fill it up again;
@bisratw
@bisratw 2 жыл бұрын
What if we put the mutex lock after the while loop, instead of using condition variable?
@Codality
@Codality 2 жыл бұрын
Master
Thread Pools in C (using the PTHREAD API)
22:54
CodeVault
Рет қаралды 41 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 114 МЛН
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 64 МЛН
Bug in Binary Search - Computerphile
11:31
Computerphile
Рет қаралды 284 М.
why do void* pointers even exist?
8:17
Low Level Learning
Рет қаралды 344 М.
How to pass arguments to threads in C
13:52
CodeVault
Рет қаралды 78 М.
Producer - Consumer Problem in Multi-Threading
25:18
CodeVault
Рет қаралды 110 М.
how Google writes gorgeous C++
7:40
Low Level Learning
Рет қаралды 837 М.
5 Tips To Write Better Python Functions
15:59
Indently
Рет қаралды 99 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 778 М.