Multithreaded Server Part 2: Thread Pools

Поділитися
Вставка
  • Опубліковано 8 лис 2024

КОМЕНТАРІ • 59

  • @benjaminshinar9509
    @benjaminshinar9509 5 років тому +40

    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 років тому +12

      Yeah, that progression seemed to make sense. Glad you enjoyed it.

  • @hc3d
    @hc3d 2 роки тому +1

    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.

  • @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.

  • @karthikp3329
    @karthikp3329 3 роки тому

    Appreciate the very useful video with a real life example and performance analysis. Good motivation for condition variables👏

  • @zachzulanas4125
    @zachzulanas4125 4 роки тому +2

    Thanks so much for this! Learned a lot for my system design class from you

  • @sydneylewis6600
    @sydneylewis6600 2 роки тому +1

    your content is amazing! Very concise, interesting, and helpful. I can't thank you enough!

  • @mrfli24
    @mrfli24 5 місяців тому

    Love every second of it

  • @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.

  • @ramub4209
    @ramub4209 4 роки тому +2

    liked it very much, can you also cover the few basics like in case of disconnections of client/server what happens etc..

  • @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

  • @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.

  • @jamesm6951
    @jamesm6951 3 роки тому +2

    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).

  • @jonasbrandenburg9025
    @jonasbrandenburg9025 2 роки тому

    This is so amazing! Thank you so much for these videos.

  • @mudaliaraditya
    @mudaliaraditya 5 років тому

    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  5 років тому +1

      Yeah, non-blocking and asynchronous io are on my list for future videos.

  • @amrtcpp6203
    @amrtcpp6203 4 роки тому

    Thank you very much

  • @lordadamson
    @lordadamson 5 років тому +2

    I love your videos ❤️ keep them coming ❤️❤️

  • @amr3162
    @amr3162 4 роки тому

    Thank you for the video

  • @drvanon
    @drvanon 5 років тому +1

    I am very curious about your solution!

  • @MrS0910241
    @MrS0910241 4 роки тому

    BEST vids ever

  • @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

  • @vaibhavgupta8048
    @vaibhavgupta8048 4 роки тому

    thanks for the awesome videos..

    • @JacobSorber
      @JacobSorber  4 роки тому

      You're welcome. Thanks for watching.

  • @J_Tanzanite
    @J_Tanzanite 5 років тому +2

    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 років тому +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~

  • @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.

  • @ruipeng1624
    @ruipeng1624 3 роки тому

    Solute!

  • @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 років тому +6

      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.

  • @ttc0419
    @ttc0419 5 років тому +2

    Could you made a video about asynchronous io like epoll?

    • @JacobSorber
      @JacobSorber  5 років тому +2

      Yes, I'm planning on in the near future.

  • @phcmaia
    @phcmaia 4 роки тому

    Great Videos , subscribing here and in patreon . Thank you.

    • @JacobSorber
      @JacobSorber  4 роки тому

      Thanks! Welcome to the channel.

  • @rishikeshpawar3230
    @rishikeshpawar3230 3 роки тому

    I love you yr, beautiful explainetion...

  • @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

  • @shaistakhan5130
    @shaistakhan5130 3 роки тому

    hii..do you have any videos for c++ on the same topic

  • @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.

  • @viper59421
    @viper59421 2 роки тому

    4:00 minecraft cave noise

  • @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.

  • @homayounshokri5041
    @homayounshokri5041 5 років тому +1

    Can you please make a tutorial on SSH?

    • @JacobSorber
      @JacobSorber  5 років тому +3

      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 років тому +1

      @@JacobSorber
      What I meant was
      Communication in secure channel like using TLS or SSL.
      Thanks

    • @JacobSorber
      @JacobSorber  5 років тому +4

      @@homayounshokri5041 Ok. I'll see what I can do.

  • @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 роки тому +1

      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.

  • @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

  • @abd5184
    @abd5184 Рік тому +1

    You speak too fast

  • @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.