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.
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.
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.
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
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.
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).
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
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?
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.
@@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~
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.
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”
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.
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
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 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.
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)?
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.
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
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.
Yeah, that progression seemed to make sense. Glad you enjoyed it.
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.
This is an excellent resource for Thread-pool. FInally understood, Thanks, Jacob!
Great to hear! Glad I could help.
Appreciate the very useful video with a real life example and performance analysis. Good motivation for condition variables👏
Thanks so much for this! Learned a lot for my system design class from you
Glad I could help!
your content is amazing! Very concise, interesting, and helpful. I can't thank you enough!
Love every second of it
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.
liked it very much, can you also cover the few basics like in case of disconnections of client/server what happens etc..
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
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.
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).
This is so amazing! Thank you so much for these videos.
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
Yeah, non-blocking and asynchronous io are on my list for future videos.
Thank you very much
I love your videos ❤️ keep them coming ❤️❤️
Thanks. Will do.
Thank you for the video
I am very curious about your solution!
BEST vids ever
Thanks! Spread the word.
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
thanks for the awesome videos..
You're welcome. Thanks for watching.
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?
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.
@@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~
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.
Solute!
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”
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.
@@JacobSorber I'm sure it was time well spent.
Could you made a video about asynchronous io like epoll?
Yes, I'm planning on in the near future.
Great Videos , subscribing here and in patreon . Thank you.
Thanks! Welcome to the channel.
I love you yr, beautiful explainetion...
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
hii..do you have any videos for c++ on the same topic
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.
I'll add it to the future video list and see what I can do.
4:00 minecraft cave noise
What's the name of your IDE? You type so faster using it with very good efficiency.
It's not really an IDE. Just VSCode and it's terminal plugin.
@@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.
Can you please make a tutorial on SSH?
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)?
@@JacobSorber
What I meant was
Communication in secure channel like using TLS or SSL.
Thanks
@@homayounshokri5041 Ok. I'll see what I can do.
dequeuing is threaded , why are we protecting enqueue, thats just enqueueing the client socket as in when they arrive .
Please respond .
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.
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
You speak too fast
can u speak more slowly pleas !! :)
I can try in future videos. :)
In the meantime, you can always reduce the playback speed.