Fork and Pthreads - A Guide To Get You Started with Multiprocessing

Поделиться
HTML-код
  • Опубликовано: 17 ноя 2024

Комментарии • 48

  • @petermainwaringsx
    @petermainwaringsx 2 года назад +12

    I did pass an aptitude test for a job as a "programmer" in the 70's but decided to stay as a radio comms engineer with the post office. All of my coding has been self taught and I do enjoy a bit of code writing but not going beyond VB, Python and some scratch with my grandchildren. I always find your videos so interesting and learn a load of stuff which I'm unlikely to use in my 70+ year old life. I still dip into your videos on encryption as they are undoubtedly the best out there.

  • @bruhstfuu
    @bruhstfuu 8 месяцев назад +1

    so helpful for my operating systems class, thank you!

  • @oraflores
    @oraflores 2 года назад +1

    Although it may date me -- "Thorin...": The Hobbit. "time passes": Zork I
    I remember my first exposure to forking years ago when modifying some "C" code to prevent zombies which are orphan children processes.
    Thank you for your videos. Always a treat to watch.

  • @jamiemcglynn6600
    @jamiemcglynn6600 2 года назад

    I have seen so much drumming up about "async" and whatnot, but it always kept me thinking whether it is true multi-tasking or just one core switching too and fro between one execution context to the next.
    I've always felt that threads was always the way to go because you're not locking execution to specific cores, and the workload scales better the more available cores there are. Yeah, sure, it's harder when race conditions come into play, but, if you have the cores, best put them to work and not have them being couch potatoes.
    Great video, Gary!

    • @TimSavage-drummer
      @TimSavage-drummer 2 года назад

      Async is more akin to cooperative multitasking.
      For workloads that are not CPU intensive or are IO heavy, it can be more efficient. A threaded solution has a lot of overhead if it's spending the majority of its time blocking on IO. Many web applications scale quite well using async when the majority of the processing time is spent essentially stalled waiting for external cache, databases or other external resources.
      Async can also work well in conjunction with threading. Can await on multiple threaded tasks to complete on the main thread while servicing other requests that may not require an entire thread.

    • @GaryExplains
      @GaryExplains  2 года назад

      You might like my video on multitasking vs multiprocessing vs multithreading. It is linked in the description.

    • @jamiemcglynn6600
      @jamiemcglynn6600 2 года назад

      @@GaryExplains Ah, must have missed that one, thanks!

    • @justadude8716
      @justadude8716 Год назад

      Go language implemented threads in an amazing way using channels, making race conditions a thing of the past!

    • @GaryExplains
      @GaryExplains  Год назад

      @@justadude8716 Interesting comment because in my video on goroutines I show how you can easily create a race condition!

  • @mortenlund1418
    @mortenlund1418 5 месяцев назад

    Great video. Thanks.

  • @filker0
    @filker0 2 года назад +2

    Before going much farther with threading, you should go over the synchronization primitives like semaphores and mutexes, and also cover thread scheduling priority.

    • @GaryExplains
      @GaryExplains  2 года назад

      Of course. I have already covered that (in part) in my Arduino dual-core programming video. But I will do a specific video about it for this series.

  • @peterjansen4826
    @peterjansen4826 2 года назад

    I am going to type over that code. :)

  • @adrianalanbennett
    @adrianalanbennett 2 года назад +1

    Thanks so much!

  • @cezarcatalin1406
    @cezarcatalin1406 2 года назад +5

    Can you do a video on windows process creation and windows threads ?
    It’s a bit different and most linux people don’t know how it functions.

    • @GaryExplains
      @GaryExplains  2 года назад +6

      Yes, if this video is well received then I will do more including looking at the Windows API.

  • @muddyexport5639
    @muddyexport5639 2 года назад +1

    Thanks!

  • @Musaafir-ln6feet
    @Musaafir-ln6feet 2 года назад +1

    I wish you can cover more educational topics in future as you have an extraordinary experience in Computer Science field this would help students like me, who wanna study higher level topis in much detail.

    • @GaryExplains
      @GaryExplains  2 года назад +1

      Thanks for the encouragement. Any particular topics you have in mind?

    • @Musaafir-ln6feet
      @Musaafir-ln6feet 2 года назад

      Topics realted to CUDA programming and High Performance Computing

    • @GaryExplains
      @GaryExplains  2 года назад

      Have you watched my "supercomputer" videos on this channel?

  • @williamstevenson2649
    @williamstevenson2649 2 года назад +3

    OK- I'll play the game: The Hobbit according to Jackson, Part 3. Maybe that's different to the book, which I haven't read. This is very interesting - I don't know anything about C and I'm not about to do any multi - core programming, but at least I now have a vague idea of what it's about

    • @GaryExplains
      @GaryExplains  2 года назад +1

      Good guess, but no! The quote is older than the movies.

  • @MrFilip121
    @MrFilip121 2 года назад +1

    Can you do a video on passing variables between processes/sharing variables(i.e. buffers) between threads? Some sort of interprocess communication

    • @GaryExplains
      @GaryExplains  2 года назад +2

      Indeed I will. I have also covered that in my Arduino dual-core programming video.

  • @KyrychenkoAnton
    @KyrychenkoAnton Год назад

    Thanks a lot! Would be great if you plan to make more multicore programming tutorials on actual mcu's like rp2040 or esp32!

    • @GaryExplains
      @GaryExplains  Год назад +1

      I am glad you found it useful. I cover multi core microcontroller programming here ruclips.net/video/w5YigjvSaF4/видео.html and in my video about programming the Pico in C, plus of course my videos about Piccolo OS

    • @KyrychenkoAnton
      @KyrychenkoAnton Год назад

      @@GaryExplains ah, sorry, I saw video you mentioned, in the end you mentioned to comment if we want to see more videos about multicore programming - so I commented of course) I just started browsing your other videos looking for it and ended up here. So sorry, I meant to comment on video you mentioned actually)

  • @SO-dl2pv
    @SO-dl2pv 2 года назад

    Could you please suggest a book or any other resource to learn more about this topic? thanks :)

  • @yngvenystrand167
    @yngvenystrand167 2 года назад +1

    Gary, is it the game released 1982 for ZX Spectrum? Ported later to TRS-80, and others?

  • @zz3709
    @zz3709 2 года назад

    Is there a correlation/connection with this and CPU cores and threads?

    • @GaryExplains
      @GaryExplains  2 года назад

      You might like my video "Multitasking vs Multithreading vs Multiprocessing" it should help answer that question - ruclips.net/video/Tn0u-IIBmtc/видео.html

    • @zz3709
      @zz3709 2 года назад

      Thanks @@GaryExplains ... that was enlightening. Only other thing in testing to figure out is how to intentionally run different tasks in one program, on different cores. I can't do this on embedded devices, but it's there a way to tell day and i5 to use a separate core for a specific task?

  • @peterjansen4826
    @peterjansen4826 2 года назад

    On line 48, why does i have to be casted with (* void)(long)?

    • @GaryExplains
      @GaryExplains  2 года назад

      Because the parameter to a thread is a void * pointer. Basically I convert the integer into a long and then pretend it is a pointer.

  • @wilsonursua8927
    @wilsonursua8927 2 года назад

    Hi Gary what happened to your speed test g channel, still hoping you could still test those new phones

    • @GaryExplains
      @GaryExplains  2 года назад

      Sadly it is on pause. It wasn't popular.

  • @chuckbiscuito
    @chuckbiscuito 2 года назад

    fork(2): call it once and it returns twice!

  • @TaureanSmoke
    @TaureanSmoke 2 года назад

    The Hobbit

  • @joakimedholm128
    @joakimedholm128 2 года назад

    this is so boring

    • @TaureanSmoke
      @TaureanSmoke 2 года назад

      That's because you're not a real nerd. Get out of here!

    • @GaryExplains
      @GaryExplains  2 года назад +1

      🤣🤣🤣 twitter.com/garyexplains/status/1580196280361308160