Тёмный

Multithreaded Server Part 2: Thread Pools 

Jacob Sorber
Подписаться 165 тыс.
Просмотров 50 тыс.
50% 1

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 59   
@benjaminshinar9509
@benjaminshinar9509 5 лет назад
it's really cool that you go from threads to thread pools and now mutex and later on conditional variables. it's just like real life, where each solution has some new problems riding along.
@JacobSorber
@JacobSorber 5 лет назад
Yeah, that progression seemed to make sense. Glad you enjoyed it.
@jamesm6951
@jamesm6951 3 года назад
At 4:03 on lines 66 you malloc storage for an int, but where do you free it? Your dequeue() functions only frees the the struct pointer which includes the memory for the client pointer itself but not for the int data which it points to. Could you please explain what I am missing (if I'm wrong).
@ramub4209
@ramub4209 4 года назад
liked it very much, can you also cover the few basics like in case of disconnections of client/server what happens etc..
@J_Tanzanite
@J_Tanzanite 5 лет назад
In the while loop you set up, couldn't you just use usleep to avoid overhead? while (true) { /* code */ usleep(1000000/24); // Sleep for 1/24th of a second. } I'm guessing this is a bad idea, due to something I am unaware of?
@JacobSorber
@JacobSorber 5 лет назад
Yeah, that works, but makes your code less responsive. If all of your threads are sleeping, and 10000 connections arrive. It could take 1/24th of a second before they start working on any of them. That may be acceptable in some cases. In others, it may not be. But, it's never going to be great. As you make the sleep time longer, you save CPU cycles and energy but get less responsive. Make it shorter, and you get more responsive but less efficient. There are some cleaner ways to avoid this conundrum. I'll try to get to them soon.
@J_Tanzanite
@J_Tanzanite 5 лет назад
@@JacobSorber Thanks for your reply, and for being so chill :) I have another question tho, will you ever put up a patron or something? Or even just a paypal address I can donate to? Love your videos, they've helped me a lot and they've inspired me to get back into C programming. Most C programming guides out there - or at least the ones I saw back in 2013 when I was beginning to learn C - were quite bad. So it makes me happy to see some good guides now coming from you. I used to write C programs for Linux before, but then I got busy with other projects and life took off in all sorts of directions. Before I knew it, I was making server plugins for games because my friend needed it, obviously the computer language I use for game servers aren't C, sadly. I've completely changed the coding style in C too, I kinda just do this now: www.kernel.org/doc/html/v4.10/process/coding-style.html Coding styles are kinda meaningless, as long as it is maintainable and the code is good, it doesn't really matter the style. Lastly, I have these two C projects of mine that I kinda... Forgot, like I said, life took off. I've thought about sharing them with you, since you wanted to do a series where you help correct code... It's just that... well the code is really bad, and I don't even write code in that way anymore xD It's a mess and makes me shameful to look at. I'll probably rewrite both of them and then share it with you later, if I get time. Then again, the code isn't exactly small... Perhaps not fitting. Anyway, love your videos, keep it up~
@hc3d
@hc3d 2 года назад
Your exaplanation of a simple server helped me immensely in setting up a simple HTTP server using C++20. The example you showed was quite elegant. I'm not sure which video it was exactly, it could have been one of your other ones. To my suprise the HTTP server is working surprisingly well with surprisingly little code.
@sydneylewis6600
@sydneylewis6600 2 года назад
your content is amazing! Very concise, interesting, and helpful. I can't thank you enough!
@ttc0419
@ttc0419 5 лет назад
Could you made a video about asynchronous io like epoll?
@JacobSorber
@JacobSorber 5 лет назад
Yes, I'm planning on in the near future.
@mattwilliams6500
@mattwilliams6500 3 года назад
its funny how just using gcc and WSL or Ubuntu makes this project tkae much longer to compile, the Makefiles pretty much never work for me. Copied everythign exactly the same but my Makefile saves in VS code as Makefile.mak, and when run prints" cc server.c -o server" and a a few errors from not seeing pthread.h or myqueue files, very frustrating. works when I write those 3 serperate compile commands out though
@throatwobblermangrove7508
@throatwobblermangrove7508 2 года назад
Thank you very effing much. Wanna see source code? Pay. And just for your convenience I am not gonna show all the code in the video - just snippets. And when I scroll the page up and down - I am gonna do it really damn fast, just so you don't see anything. Quite helpful.
@sushantprajapati3092
@sushantprajapati3092 4 года назад
Sir The backlog parameter of listen is 5 And server is taking 2 sec time in serving 1 client Server is not multithreaded A shell script is running 50 client programs in background at nearly same time. So some connections should fail since backlog parameter is 5 But no connection is failing..every client is being served at the interval of 2sec
@sairas5170
@sairas5170 2 года назад
Hello Mr. Jacobs, your video are very helpful and knowledgeable. Can you do same video of handling multiple clients upto 50 in python script please it will help lot to understand the concept. Thank you for inspiring and uploading such nice videos.
@santhoshreddy1284
@santhoshreddy1284 3 года назад
Hi jacob, thanks for your video. Your class is amazing. can you please tell me from where i can download the code which you have shown in this video
@zachzulanas4125
@zachzulanas4125 4 года назад
Thanks so much for this! Learned a lot for my system design class from you
@JacobSorber
@JacobSorber 4 года назад
Glad I could help!
@lordadamson
@lordadamson 5 лет назад
I love your videos ❤️ keep them coming ❤️❤️
@JacobSorber
@JacobSorber 5 лет назад
Thanks. Will do.
@drvanon
@drvanon 5 лет назад
I am very curious about your solution!
@mrfli24
@mrfli24 4 месяца назад
Love every second of it
@hari1134
@hari1134 5 лет назад
Hai jack sorber ,,, your videos are very crisp and to the point ... It gives lots of new angles to the concepts ... really helpful ... could u do a video on booting sequence of a system ... an embedded system or any system ... thereby explaining terminologies like bootloader, initrd, initramfs, bootstrap program etc. i found some articles and videos on the internet ... but your version would make things more clear
@karthikp3329
@karthikp3329 2 года назад
Appreciate the very useful video with a real life example and performance analysis. Good motivation for condition variables👏
@viper59421
@viper59421 2 года назад
4:00 minecraft cave noise
@nwo-congo3107
@nwo-congo3107 4 года назад
Can you put up a Tutorial how to use the and heavy modified OpenSSL API for Server sockets? Any older 1.0.2.x OpenSSL code is now broken and lots of tutorials are now out of date and doesn't compile anymore. I was not lucky finding any working peace of code for OoenSSL current, its a mess. Thx.
@JacobSorber
@JacobSorber 4 года назад
I'll add it to the future video list and see what I can do.
@shaistakhan5130
@shaistakhan5130 3 года назад
hii..do you have any videos for c++ on the same topic
@jonasbrandenburg9025
@jonasbrandenburg9025 2 года назад
This is so amazing! Thank you so much for these videos.
@rishikeshpawar3230
@rishikeshpawar3230 3 года назад
I love you yr, beautiful explainetion...
@amarjeetSingh-bc6qz
@amarjeetSingh-bc6qz 4 года назад
dequeuing is threaded , why are we protecting enqueue, thats just enqueueing the client socket as in when they arrive . Please respond .
@idk-bv3iw
@idk-bv3iw 4 года назад
You would still have two threads (the producer and one of the consumers) accessing and modifying the same variables (head and tail). This leads to data races, which are undefined behaviour. The general condition is that two threads access the same memory location and at least one of them is a write. I can't think of a specific example here but I'm certain that something can (and will) go wrong if you enqueue and dequeue at the same time.
@mudaliaraditya
@mudaliaraditya 4 года назад
thank you so much,you teachings and and efforts i really dont know how to thank you! i love the depth at which you teach could u kindly do something for networks as well i mean select poll or epoll, non blocking servers
@JacobSorber
@JacobSorber 4 года назад
Yeah, non-blocking and asynchronous io are on my list for future videos.
@mockingbird3809
@mockingbird3809 3 года назад
This is an excellent resource for Thread-pool. FInally understood, Thanks, Jacob!
@JacobSorber
@JacobSorber 3 года назад
Great to hear! Glad I could help.
@amymayadi
@amymayadi 4 года назад
What's the name of your IDE? You type so faster using it with very good efficiency.
@JacobSorber
@JacobSorber 4 года назад
It's not really an IDE. Just VSCode and it's terminal plugin.
@amymayadi
@amymayadi 4 года назад
@@JacobSorber Thank you for your reply so quick. I like your videos and I will keep up with your videos. Thank you that you make the knowledge to be more easily obtained and it is quite clear after your lessons, which is short and focus on the most important parts.
@angledcoathanger
@angledcoathanger 5 лет назад
Man, your videos are so clear and helpful. Thank you. I mean this with the most possible respect, but did you realise that if you say your full name quickly enough it sounds like you absorb Jakes? “Jake Absorber”
@JacobSorber
@JacobSorber 5 лет назад
Thanks. Glad you're enjoying them. Yeah, there are many variants on the "absorber" jokes, including creative pronunciations to make it sound like "shock absorber". One semester, my students were (reportedly) referring to me as simply "the absorber" because my projects were taking up more of their time than they wanted them to.
@angledcoathanger
@angledcoathanger 5 лет назад
@@JacobSorber I'm sure it was time well spent.
@amrtcpp6203
@amrtcpp6203 4 года назад
Thank you very much
@homayounshokri5041
@homayounshokri5041 5 лет назад
Can you please make a tutorial on SSH?
@JacobSorber
@JacobSorber 5 лет назад
Specifically, what do you have in mind? Are we talking about using ssh-like just working in a remote terminal-or are you more thinking about programming with encrypted communication channels (using something like openssl)?
@homayounshokri5041
@homayounshokri5041 5 лет назад
@@JacobSorber What I meant was Communication in secure channel like using TLS or SSL. Thanks
@JacobSorber
@JacobSorber 5 лет назад
@@homayounshokri5041 Ok. I'll see what I can do.
@amr3162
@amr3162 4 года назад
Thank you for the video
@phcmaia
@phcmaia 4 года назад
Great Videos , subscribing here and in patreon . Thank you.
@JacobSorber
@JacobSorber 4 года назад
Thanks! Welcome to the channel.
@ruipeng1624
@ruipeng1624 3 года назад
Solute!
@vaibhavgupta8048
@vaibhavgupta8048 3 года назад
thanks for the awesome videos..
@JacobSorber
@JacobSorber 3 года назад
You're welcome. Thanks for watching.
@stigmate8238
@stigmate8238 4 года назад
can u speak more slowly pleas !! :)
@JacobSorber
@JacobSorber 4 года назад
I can try in future videos. :) In the meantime, you can always reduce the playback speed.
@abd5184
@abd5184 Год назад
You speak too fast
@tntcaptain9
@tntcaptain9 3 года назад
Thanks for the video! If you haven't noticed, this queue problem which Jacob tried to address is also known as Producer Consumer problem. Now go open your class notes to understand in depth about it.
@MrS0910241
@MrS0910241 4 года назад
BEST vids ever
@JacobSorber
@JacobSorber 4 года назад
Thanks! Spread the word.
Далее
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
Thread Pools in Java
18:04
Просмотров 67 тыс.
Multithreading Code - Computerphile
15:54
Просмотров 385 тыс.
Microservices are Technical Debt
31:59
Просмотров 388 тыс.
Malware Development: Processes, Threads, and Handles
31:29
How different are C and C++? Can I still say C/C++?
10:25
Another way to check pointers at runtime in C
12:16
Просмотров 12 тыс.
Master Multithreading : Thread Pool In C++
20:19
Просмотров 10 тыс.