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

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ต.ค. 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 7 หลายเดือนก่อน +1

    so helpful for my operating systems class, thank you!

    • @GaryExplains
      @GaryExplains  7 หลายเดือนก่อน +1

      Glad it was helpful!

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

  • @mortenlund1418
    @mortenlund1418 3 หลายเดือนก่อน

    Great video. Thanks.

    • @GaryExplains
      @GaryExplains  3 หลายเดือนก่อน

      Glad you liked it!

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

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

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

  • @peterjansen4826
    @peterjansen4826 ปีที่แล้ว

    I am going to type over that code. :)

  • @adrianalanbennett
    @adrianalanbennett 2 ปีที่แล้ว +1

    Thanks so much!

  • @muddyexport5639
    @muddyexport5639 2 ปีที่แล้ว +1

    Thanks!

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

  • @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 th-cam.com/video/w5YigjvSaF4/w-d-xo.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 :)

  • @peterjansen4826
    @peterjansen4826 ปีที่แล้ว

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

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      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.

  • @yngvenystrand167
    @yngvenystrand167 2 ปีที่แล้ว +1

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

  • @zz3709
    @zz3709 ปีที่แล้ว

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

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      You might like my video "Multitasking vs Multithreading vs Multiprocessing" it should help answer that question - th-cam.com/video/Tn0u-IIBmtc/w-d-xo.html

    • @zz3709
      @zz3709 ปีที่แล้ว

      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?

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