Mutex Introduction (pthreads) | C Programming Tutorial

  Рет қаралды 20,003

Portfolio Courses

Portfolio Courses

2 жыл бұрын

How to use a mutex to prevent race conditions in a multi-threaded C program using the POSIX pthread library. Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!

Пікірлер: 45
@16mobs50
@16mobs50 10 ай бұрын
i cannot emphasize enough on how helpful your entire channel is. thank you!!
@dzeno7370
@dzeno7370 2 жыл бұрын
I wish I had those videos a couple years ago when I was studying for my exams. Keep up the good work !
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you for the kind feedback! 😀
@widowedsock
@widowedsock Жыл бұрын
I'm watching these for my exams and they're so helpful
@pituboy
@pituboy 11 ай бұрын
The YT algorithm just does a great work today, but I really wish I can use this video as my reference 2 years ago and complete my project at uni.
@KentakiAli
@KentakiAli 10 ай бұрын
Great explanations, thank you for this tutorial! helping me a lot for my exam prep :).
@GavinPicard
@GavinPicard 3 ай бұрын
5 days overdue on an assignment. -10 points per day. I am only get 50 points credit but I am fighting through. Thanks for this video.
@PortfolioCourses
@PortfolioCourses 3 ай бұрын
You're welcome! :-) And good for you for fighting through - you got this!
@M3t4lik
@M3t4lik Жыл бұрын
Great video on thread handling, your the best :)
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thank you for the positive feedback, I’m very glad you enjoyed the video! :-)
@TK-ko3fg
@TK-ko3fg Жыл бұрын
thank you so much guys, this helped me to catch up with my OS class
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're very welcome, I'm glad to hear this video was able to help you out with your OS class! :-)
@muhammadgheith2492
@muhammadgheith2492 Жыл бұрын
fantastic explination, thank you!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Muhammad! :-)
@scramjet4610
@scramjet4610 Жыл бұрын
Excellent explanation of a tricky subject.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I’m glad you enjoyed the explanation, and thank you for the positive feedback! :-)
@abeashvil1393
@abeashvil1393 Жыл бұрын
This video really helped! Thanks a ton
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Abe! :-)
@Darwho
@Darwho Жыл бұрын
Amazing voice, comments on your file and examples that are simple. It's also good that the jargon explained before using it and that the videos are concise. If you haven't corrected it already, it could be even better if you managed to cut the mouse and keyboard sounds. Anyway, keep up the good work ! It helps me with my system classes.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thank you, I'm glad you enjoy the video! Oddly enough, most people enjoy the keyboard and mouse sounds so I keep those in. :-)
@bee14ish
@bee14ish Жыл бұрын
@@PortfolioCourses Yeah, I found the video helpful as well. The keyboard and mouse sounds are kinda like a weird form of ASMR if that makes sense lol
@rajprasadshrestha6963
@rajprasadshrestha6963 Жыл бұрын
Excellent explanation thanks 😅!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Raj! 😀
@depsylon4235
@depsylon4235 Жыл бұрын
again very easy to follow, but I think it may would've been nice to see how long the program takes with and without the lock (assuming the difference is visible here).
@PortfolioCourses
@PortfolioCourses Жыл бұрын
That's a neat idea! :-) The source code is available here if anyone wants to try this as a fun follow-up "exercise": github.com/portfoliocourses/c-example-code/tree/main/mutex.
@RoockYou
@RoockYou 2 жыл бұрын
thank you so much man
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re very welcome! :-D
@lawniczakjohn
@lawniczakjohn 11 ай бұрын
Love it baby!
@1CProgrammer
@1CProgrammer Жыл бұрын
thankyou verymuch i hope you get more subs and make more good contents.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're very welcome, I'll definitely keep making more content! :-)
@dijkstra4678
@dijkstra4678 2 жыл бұрын
very nice
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you! :-)
@vibhashreehippargi8233
@vibhashreehippargi8233 Жыл бұрын
Hello Sir, i tried the same code in my Visual studio environment, some times it gives output as 500 and sometimes 200/300 (each run one value). I donot understand what is going wrong.Could you please help?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Hmm, I'm not sure what could be happening Vibhasree. :-( The code in the video is available here: github.com/portfoliocourses/c-example-code/tree/main/mutex. Maybe try using that exact code if you weren't already? Perhaps there is a small difference that is causing the bug. The other issue is that POSIX threads are a "Unix-like system" tool, on Windows different libraries are available for threads: www.reddit.com/r/C_Programming/comments/rpd2w3/is_there_a_way_to_use_posix_standard_in_visual/. So it may be due to the fact that you are trying to use POSIX on a Windows machine, though that said I believe there are ways to use POSIX on Windows as well.
@vibhashreehippargi8233
@vibhashreehippargi8233 Жыл бұрын
@@PortfolioCourses Hello sir, thank you for your reply.I used the exact same code from your git already. Also included windows.h. Each run in Visual studio displays different answer and has different Process Ids. Will have a look once again at the link you shared. Also, thank you for the amazing explanation.You make it interesting to learn how to code. Thank you!😊
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@vibhashreehippargi8233 You're welcome! 🙂 And if that's the case it makes me wonder if it's a situation where the POSIX threads just aren't supported on Windows, because it should work on a Unix-like system.
@sahandanushka7371
@sahandanushka7371 11 ай бұрын
At 9:38, should the read balance be 200?
@PortfolioCourses
@PortfolioCourses 11 ай бұрын
Yes it should be 200.
@Ninja_Sh11
@Ninja_Sh11 Жыл бұрын
may you give a tutorial about binary semaphore ..
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I have added that to my list of video ideas Neeraj! :-)
@Ninja_Sh11
@Ninja_Sh11 Жыл бұрын
@@PortfolioCourses okay I'll try
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@Ninja_Sh11 Good luck! 🙂
@Ninja_Sh11
@Ninja_Sh11 Жыл бұрын
@@PortfolioCourses Actually , Just before my comment i had give an interview for embedded c/c++ developer in UST Global ..and asked the question about semaphore..henceforth i asked you about semaphore.... thanks for comment ..and keep it up
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@Ninja_Sh11 Cool, I hope you get the job!
@zz3709
@zz3709 4 ай бұрын
Great content, but I'm never a fan of creating variables that look like keywords (ie: "mutex" in this case). Just adds more confusion. Maybe something like "acct_write_key", etc.
clearerr() Function | C Programming Tutorial
13:08
Portfolio Courses
Рет қаралды 1,7 М.
Detached Threads (pthreads) | C Programming Tutorial
12:34
Portfolio Courses
Рет қаралды 4,5 М.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 120 МЛН
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Chapitosiki
Рет қаралды 4,2 МЛН
НЫСАНА КОНЦЕРТ 2024
2:26:34
Нысана театры
Рет қаралды 1,6 МЛН
CHOCKY MILK.. 🤣 #shorts
00:20
Savage Vlogs
Рет қаралды 19 МЛН
Introduction to semaphores in C
12:24
CodeVault
Рет қаралды 123 М.
What is Mutex in C++ (Multithreading for Beginners)
12:29
CodeBeauty
Рет қаралды 41 М.
Introduction To Threads (pthreads) | C Programming Tutorial
13:39
Portfolio Courses
Рет қаралды 89 М.
Fork and Pthreads - A Guide To Get You Started with Multiprocessing
17:28
What is a mutex in C? (pthread_mutex)
9:18
CodeVault
Рет қаралды 160 М.
How To Return An Array From A Function | C Programming Tutorial
13:01
Portfolio Courses
Рет қаралды 64 М.
Binary File Access Introduction | C Programming Example
16:17
Portfolio Courses
Рет қаралды 25 М.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 120 МЛН