Why Are Threads Needed On Single Core Processors

Поділитися
Вставка
  • Опубліковано 30 січ 2025

КОМЕНТАРІ • 495

  • @CoreDumpped
    @CoreDumpped  2 місяці тому +32

    This video was sponsored by Brilliant.
    To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/CoreDumped. You’ll also get 20% off an annual premium subscription.

    • @JesusPlsSaveMe
      @JesusPlsSaveMe 2 місяці тому +3

      Where are you going after you die?
      What happens next? Have you ever thought about that?
      Repent today and give your life to Jesus Christ to obtain eternal salvation. Tomorrow may be too late my brethen😢.
      Hebrews 9:27 says "And as it is appointed unto man once to die, but after that the judgement

    • @knowmore7138
      @knowmore7138 2 місяці тому +1

      i have been started watching your video recently and you know what your videos are great cuz for me they are easy to comprehend. i also had an humble request can you make some videos on computational structure, please!!!

    • @luanon404
      @luanon404 2 місяці тому

      what program did u use to make video?

    • @petromudrievskyj
      @petromudrievskyj Місяць тому

      Brilliant? - lame

  • @exe.m1dn1ght
    @exe.m1dn1ght 2 місяці тому +288

    Man your videos are diamonds.. I am so blessed that i found you

    • @CoreDumpped
      @CoreDumpped  2 місяці тому +25

      Welcome aboard!

    • @kaiyueguo1624
      @kaiyueguo1624 2 місяці тому +2

      Same

    • @Vladimir93459
      @Vladimir93459 2 місяці тому +1

      @@CoreDumpped Where i Can find any course like this

    • @adamrushford
      @adamrushford 2 місяці тому

      utterly useless info with a robot voice, you're just his alt account i think

    • @YaGirlLumi
      @YaGirlLumi Місяць тому +1

      @@adamrushford nah, do your research man

  • @Izz4cc
    @Izz4cc 2 місяці тому +139

    I have always wondered what the actual difference between threads and cores are, and YOU are the first one to explain it in a way that can be perfectly understood. Your animation style is also really great.

    • @f14v14n
      @f14v14n 2 місяці тому +10

      Are you sure you are referring to the same thing? I've always wondered about hardware multi threading (as in intel's hyper threading) and initially thought this video is going to explain those, but it seems it's the OS concept of threads (which is also interesting).
      Or maybe I got it wrong, who knows.

    • @ArneChristianRosenfeldt
      @ArneChristianRosenfeldt 2 місяці тому

      @@f14v14nhyper threading is a marketing term. There are two cores who share some resources like main memory and cache. And hyper threading refers to sharing of seldomly used compute circuits like division, floating point coprocessor , and MMX . No registers are shared.

    • @by010
      @by010 2 місяці тому +10

      Thats cause in terms of hardware, threads is also language to say "concurrent threads processing capability". 1 word 2 meanings. So that my CPU has 8c16t means it has 8 physical cores and capability of doing 16 things at once. But in my OS probably there is over 1000 threads.

    • @Izz4cc
      @Izz4cc 2 місяці тому +1

      @@by010 16 threads per core?

    • @BlackDub21
      @BlackDub21 2 місяці тому +2

      I understand, now!

  • @varmaggv
    @varmaggv 2 місяці тому +11

    This was awesome, eagerly waiting for more videos.
    Thank you for explaining it in such detail while making it simple to visualise/understand 🙌

  • @floppypaste
    @floppypaste 2 місяці тому +293

    Dude i just went to your channel to see if the new threads video is out, and i see that it has been released 30 seconds ago :D

  • @nelson.ferraz
    @nelson.ferraz 2 місяці тому +29

    Another amazing video!
    I would suggest the following definition: "a thread is an execution context".
    I think that's a good way to think about threads because they provide everything needed to run the next instruction, like its own program counter, stack, and registers.

    • @Vladimir93459
      @Vladimir93459 2 місяці тому

      Where i Can find any course like this .

  • @mfiaz7719
    @mfiaz7719 Місяць тому +5

    This is by far the best animation and explanation I have seen on UA-cam about Process vs Threads

  • @pandabearguy1
    @pandabearguy1 2 місяці тому +43

    The more you know and understand about how modern hardware and software works, the more unbelieveable it is.

  • @mehmetzeynelozkan9029
    @mehmetzeynelozkan9029 2 місяці тому +76

    BRO Just to late 2 hours ago i have operating system exam and the question is why we need threads on single core porcessors.

  • @unfgredgt
    @unfgredgt 2 місяці тому +6

    Thanks!

    • @Vladimir93459
      @Vladimir93459 2 місяці тому

      Where i Can find any course like this

  • @stratfanstl
    @stratfanstl 17 днів тому +1

    Besides the technical clarity of this video being outstanding, the audio quality of the narration is literally perfect. Would be interesting to see how this was produced.

    • @Oohio2
      @Oohio2 16 днів тому +1

      It’s text to speach (most likely ai enhanced) , not saying that this is sth bad though

    • @annakelley7513
      @annakelley7513 16 днів тому +1

      ⁠right, sounds very much like ai but it’s pretty good in my opinion

  • @ikakat2730
    @ikakat2730 8 днів тому

    that's the most beautiful explanation i've ever seen or heard: with its beauty in explaining complex notions in a simple yet vivid way - colourful, using extensive graphics and succinct; and, what's more, DETAILED(!), meaning FINE-GRAINED

  • @neoanderson1865
    @neoanderson1865 27 днів тому

    My god the amount of information packed in 16 minutes is insane. Thank you for the work you do!

  • @check9094
    @check9094 Місяць тому +1

    This is the best video I've watched on this. This helped me gain a more intuitive understanding of threads vs processes, whereas a lot of other explanations confused me.

    • @annakelley7513
      @annakelley7513 16 днів тому

      I wish it was published when I was studying threads 😊

  • @artvor0
    @artvor0 2 місяці тому +12

    People really need to understand that videos like these are better learning tools than books or people explaining it to you with just words and PDF files on board screen.

  • @giorgiobarchiesi5003
    @giorgiobarchiesi5003 2 місяці тому +2

    Thank you so much for this video, that I have found absolutely accurate, and with excellent graphics.
    I can confirm that on Solaris (the UNIX flavour that used to run on SUN workstations), threads were based on lightweight processes.
    I also remember that prior to the Posix standard for threads, portability among different O.S.’s was very challenging.
    And I would also stress the fact that when it comes to threads, with great power come great responsibilities, especially when handling concurrent access to shared data structures, and more in general, thread synchronization. A whole field of study, in I.T. science, is dedicated to this, and one has to master it perfectly in order to build correct and robust multithreaded S/W.

  • @nollix
    @nollix 2 місяці тому

    EXCELLENT presentation. You did it basically exactly the way I would like to have it explained. Perfect, down to using different colors for different processes/threads, etc.

  • @Baka100
    @Baka100 2 місяці тому +26

    make video on allocating memory on heap vs stack,
    also about the virtual memory, segmentation and pages and how are they managed using tables and shit

  • @NikolaNevenov86
    @NikolaNevenov86 2 місяці тому +14

    When deciding should I go with Threads or Process spawn for a project I remember reading that the difference between Threads and Processes is that Threads share the same memory while Processes not.

    • @robuandrei5969
      @robuandrei5969 Місяць тому +1

      That's why the famous Philosopher around the table problem is so good. Try implementing the logic of the philosophers around the table sharing forks to take turns eating using both Threads and Processes and you will quickly understand the 'memory space' dillema.
      Once you finished the implementation try using 200 philosophers in each case and see how your computer reacts :)

    • @NikolaNevenov86
      @NikolaNevenov86 Місяць тому

      @@robuandrei5969 yeah that's something I should try implementing, but I got the issue small scale when I was poking into synchronization in Vulkan.

  • @gilangwahyu4450
    @gilangwahyu4450 2 місяці тому +1

    I'm learning computer from the ground-up. Watched view videos from this channel about logic and processor, thanks for the videos..
    Now im learning softwareside and now this video helped to get the concept

  • @yudhisthir7247
    @yudhisthir7247 2 місяці тому

    The best thing is I found your channel. I never would have been learned about thread with such clarity. Thank you so much.❤

  • @discodansin7339
    @discodansin7339 2 місяці тому

    These videos are truly excellent and I'm amazed and grateful you still have more planned!

  • @luiscarlosjayk
    @luiscarlosjayk 2 місяці тому

    I really really loved this explanation. The visual way you explain it make it much easier to grasp. Thanks a lot for this!!!

  • @b.c.8102
    @b.c.8102 Місяць тому +3

    Great video ! I would recommend a small correction though. Around 14:30 you said that TEXT and DATA section are two regions that are never written too. This is mostly true, but remember that the data section is where static variables are stored. So if a Thread has to change a static variable it will write into the data section.

    • @johnadriaan8561
      @johnadriaan8561 Місяць тому

      +1 this. He probably meant CDATA (the constant data), but yes, DATA is 100% modifiable, and needs to be protected for multiple thread access

    • @saleh8568
      @saleh8568 6 днів тому

      Static variables don't change

    • @b.c.8102
      @b.c.8102 4 дні тому

      @@saleh8568 You are thinking of constant variables. Static variables are mutable.

  • @Channel-yl5kb
    @Channel-yl5kb Місяць тому

    Your videos are fascinating. You made me interested in the work of operation systems. Schematics are great for explaining stuff like this. Keep the quality

  • @SudhirPratapYadavP23IRM001
    @SudhirPratapYadavP23IRM001 Місяць тому

    Great video, never seen such precise, succinct and clear explanation on this topic.
    It shows how your understanding is deep and broad at same time.
    Thankyou so much.

  • @SzBenedek2006
    @SzBenedek2006 2 місяці тому +27

    Best channel for PROgrammers

  • @portalwalker_
    @portalwalker_ 2 місяці тому +6

    I don't think there was really anything in this video that I didn't knew before. But it still helped me to put so many things together in my head and get a much better understanding. Thank you

  • @aadishm5915
    @aadishm5915 Місяць тому

    Awesome Video as always!
    Impressed by your Animations as they make it really easier to understand!
    Thank You.

  • @YangBudhipul
    @YangBudhipul 2 місяці тому

    your video's always the best and easy to understand. I was struggling imagining all these stuffs during my computer science study

  • @sushaanthsureshkumar2126
    @sushaanthsureshkumar2126 Місяць тому

    Please keep posting videos like these (related to OS and Computer Hardware related stuff). ❤

  • @monilcharola6873
    @monilcharola6873 11 днів тому

    God bless this guy!!! Thank you very much for creating such resourceful and easy to understand videos. I have binged all the videos in your channel in past few days!

  • @AnthonyMarchenko
    @AnthonyMarchenko 15 днів тому

    Thank you for another great video! No one asked, but here’s another example of data parallelism and why it can be useful.
    You can parallelize the following operations on a sequence:
    • map
    • filter
    • reduce
    Additionally, you can use parallel sorting algorithms, but not every sorting algorithm is suitable. Only those that align with the “divide and conquer” strategy can be effectively parallelized.
    For example, merge sort consists of two main operations:
    1. Sort: This has a time complexity of O(n * log n)
    2. Merge: This has a time complexity of O(n)
    You can perform the sorting phase in parallel processes and then merge the results in the main process, as merging is relatively efficient with its linear complexity O(n)
    Cheers!

  • @gammex7441
    @gammex7441 Місяць тому

    In one of my computer science classes (several years ago), my teacher told me that a process can be used to share memory resources and a thread to share computing resources.
    Great video !

  • @heisen6376
    @heisen6376 11 днів тому

    Good Job on explaining, looking forward for more.

  • @pakkiaman2
    @pakkiaman2 2 місяці тому +4

    bro.... your're broking the internet with these AWSOME AWESOEM CONTENTS !!!!!! 10++++++++++++++++++ i'm speechless for the quality and the effort profused !!!!!!!!!!!!!!

  • @archer-sh
    @archer-sh 2 місяці тому +1

    I knew it most of the stuff except the text part in the process with how threads access them, now threads are mostly sorted in my mind thanks.

  • @bodycowlin
    @bodycowlin Місяць тому

    Oh we're getting spoiled now. The extra smooth 60fps is *chef's kiss*. Excellent video as always Jorge!

  • @richardnicholas2957
    @richardnicholas2957 Місяць тому

    It is impossible to overstate how well done this video is. 👏🏻

  • @chyldstudios
    @chyldstudios 2 місяці тому +1

    Perfect explanation of threads vs processes!

  • @vinsinin
    @vinsinin 2 місяці тому

    I was waiting for your next video. Nice Work!

  • @j-twd930
    @j-twd930 2 місяці тому +4

    Will you be teaching anything about networking? Would really like to know the low levels of how data goes from someone's server to my computer.
    That is basically magic for me, how thousands of devices share the same fiber optic line and can communicate completely fine.

    • @ArneChristianRosenfeldt
      @ArneChristianRosenfeldt 2 місяці тому +1

      Only two devices sit on a Fiber (at the ends ). Manufacturing seems to have advanced to make the individual finer thinner . And diodes are packed more dense at the ISP side. Basically an (O)LED display for download and a camera for upload.

    • @cinderwolf32
      @cinderwolf32 Місяць тому +1

      In a word, which requires a bit of research: "Multiplexing".

  • @Julian-tf8nj
    @Julian-tf8nj 2 місяці тому

    the clearest explanation of threads I've ever heard, thank you!

  • @Ahmedsb12
    @Ahmedsb12 2 місяці тому +1

    Bro cooks with every video he makes. one of the best channel out there. I'm cheering for u to continue. I believe that in a few years, your channel will become the ultimate compilation of everything there is to now about programming. Best of luck to u ❤

  • @RayanMADAO
    @RayanMADAO 2 місяці тому

    I love that you show concrete examples it makes it so much easier to understand

    • @annakelley7513
      @annakelley7513 16 днів тому

      Right! Examples are awesome and make it less abstract

  • @stefanoragone569
    @stefanoragone569 2 місяці тому

    You are amazing. Can explain these concepts so perfectly

  • @hidekxyz
    @hidekxyz 11 днів тому

    kind of reminds me of Erlang processes, which seems to be a more specific implementation for handling lightweight and fast message passing (such as handling real time), while OS threads are more suited for more general purpose applications that have concurrency needs
    Really don't know the specifics of it, but when running an OTP application, every OS thread is used to run the Erlang VM (BEAM), and just like an OS, every process is isolated until specified. Crashes and runtime errors are self-contained in the Erlang process and special processes can be used to automatically restart processes when they crash (called supervisors)

  • @TheOpethprs
    @TheOpethprs 2 місяці тому +4

    Last bit of threads executing the same piece of code clarifies a lot of confusion. Since it’s read-only and is fetched-decoded-executed.
    Brilliant explanation with careful wording. Love your videos.

  • @rafaelperez4403
    @rafaelperez4403 3 дні тому

    The prime of this channel never ends. Saludos de uruguay

  • @AheadInsaneGamer
    @AheadInsaneGamer 2 місяці тому

    Love it ! Make a series on it ❤, can you explain coroutines with your animations .

  • @SuperCraft1999
    @SuperCraft1999 2 місяці тому +5

    Perfect timing to watch during lunch

  • @RatanBasak-f8h
    @RatanBasak-f8h 2 місяці тому

    Just loved it .
    Please make more video tutorials. And I am ready to watch a 10-12 hours course on this topics with actual coding demonstration

  • @Eeatch
    @Eeatch Місяць тому

    Man you're THE BEST! Much much appreciation! Thank you!

  • @AkhileshMithran
    @AkhileshMithran Місяць тому

    Great video, hats off to your efforts.

  • @grandadmiralthrawn66
    @grandadmiralthrawn66 Місяць тому

    Sir, you deserve a medal for making Operating Systems and Computer Architecture cool.

  • @LycheeLele-mh2ku
    @LycheeLele-mh2ku Місяць тому

    Graduated from Uni and somehow threads were just glossed over. Though I've used them, I had never really taken the time to learn much about them until today. Thanks!

  • @zezinhun
    @zezinhun Місяць тому

    Your channel is ameazing!! Congratulations!

  • @wiseskeshom4673
    @wiseskeshom4673 2 місяці тому

    Your videos are absolutely brilliant, many thanks for the great work.

  • @ForestValleyGame
    @ForestValleyGame 26 днів тому

    It's worth to know that in programming languages there's a concept of thread pools as an optimization method to avoid new thread spawning each time. And in Java there is a concept of virtual threads which are some kind of a wrapper on OS threads giving more efficiency

  • @ashutoshsinghai713
    @ashutoshsinghai713 Місяць тому

    Awesome video
    I was also wondering if you are interested in making a video on the asynchonous programming, and how that works under the hood. For a long time I though the async keyword in javascript or python creates a new thread of execution, but I was wrong. Actually it's the event loop that manages the execution of these codes.
    I would like to explore this in much depth, but if you could make a video comparing this alongside the threads, it would be a huge help.
    Thanks for making this video and others in your channel, they are really in depth and informative.

    • @CoreDumpped
      @CoreDumpped  Місяць тому

      I will, but you guys need to wait because making these videos is time consuming!

  • @AMcAFaves
    @AMcAFaves 2 місяці тому

    Thanks for this excellent video on threads. When you mentioned them, it made me wonder how asynchronous functions work under the hood. Are you going to do a video on asynchronous functions?

  • @knecht3000
    @knecht3000 2 місяці тому +3

    These animations are awesome! Which programms/tools are you using for your videos?

    • @eis3nheim
      @eis3nheim 2 місяці тому

      It's been stated in previous videos that he is using PowerPoint.

  • @drbalontotis2474
    @drbalontotis2474 Місяць тому

    bro this video so cool, pls make another for hardware threads.

  • @yanglijian
    @yanglijian 2 місяці тому

    My brain starts to grow again, thanks mate. Love you so much.

  • @nicolasbertozzo2997
    @nicolasbertozzo2997 Місяць тому

    I have a test about this topic and the next video's tomorrow haha, pretty awesome video

  • @abhijitsarkar482
    @abhijitsarkar482 Місяць тому

    Amazing video, great explanation!!

  • @vartan_babayan_4388
    @vartan_babayan_4388 Місяць тому

    Great Animation! Thank You!

  • @k98killer
    @k98killer Місяць тому

    This series is great. Is there a plan to cover asynchronous runtimes in the future?

  • @ArnCiS96
    @ArnCiS96 Місяць тому

    Nice waiting for multi-core video, if we see in future video related to GPU that would be fantastic, how vertex and pixel shaders works and etc, that would be fantastic.

  • @ScienceOnTech
    @ScienceOnTech Місяць тому

    this information is amazing!
    thanks!

  • @mohamedmabrouki1680
    @mohamedmabrouki1680 Місяць тому

    amazing and intense video just one detail i would like to point is that c and c++ are mostly considered mid-level languages since they can be written and understood by humans but they give you some of the power of booth high and low level languages.
    the video really anwered a lot of questions that i had in my mind thankss.

  • @Endar92
    @Endar92 Місяць тому

    Modern languages makes it "easy" to multithread. In iOS, with Objective-c and earlier Swift versions, we needed to use the "Grand Central Dispatch" API to run code in a multithreaded way. It wasn't hard but sometimes, it could lead to messy code. In the newer swift versions, if we put any code in a "Task { code... }" block, it automatically creates threads in the background so it is very easy to create high performing, async, multihreaded, memory safe applications, everything is managed in the OS.

  • @MartinWanker-sm9uy
    @MartinWanker-sm9uy 2 дні тому

    I'm a Software Engineer with 10+ years of experience and I learned things. Great video!

  • @gumbilicious1
    @gumbilicious1 2 місяці тому

    Before watching, I am gonna guess threading is important at least in part because there would be quite a bit of processor downtime/inefficiency if tasks were not sharing time on a core. That is the first thing that popped into my head, if a core was just in charge of one task then it’d be idling quite a bit waiting for things like memory to be retrieved or user input, etc. I may be misunderstanding the subject though because I don’t know hardware that well
    Edit: I was not wrong, but only because I was so vague in my prediction. What a clever explanation, now I have a better understanding when I am using threading in my programs, this will help me design better

  • @itscryonim
    @itscryonim 2 місяці тому

    At 3:10, whilst you do mention that each process traditionally has 1 program counter, the solution after a long explanation is to simply have multiple program counters, along with sharing of the rest of the resources. I think that could have been better explained because I was waiting for a much different approach to the problem, than a simple, "but to run multiple tasks in a process, OS' use a different approach than the traditional process model", but if it is not a different process model then it's not wholly correct to say that "in traditional process model, one process can only have one program counter" (something along those lines).

  • @frostcs
    @frostcs 27 днів тому

    @CoreDumped Amazing video one of the best explanations of threads I have seen so far! It would be great if you can also cover the actor model as well

  • @saifayman3984
    @saifayman3984 2 місяці тому

    I can see that a lot of effort has been done on this video that even though thankfully I know this info I am still urged to watch it

  • @Anshulkatta
    @Anshulkatta Місяць тому

    With Virtual threads in Java 23, you can have millions of virtual threads in JVM on a platform thread, that means good resource utilization

  • @talladasaikrishna
    @talladasaikrishna Місяць тому

    Very nice video and explanation. When can we expect the next video?

  • @darpmosh6601
    @darpmosh6601 2 місяці тому

    Thank you CoreDumped, very cool!

  • @skilz8098
    @skilz8098 2 місяці тому

    This ought to be interesting when you start to get into the idea of mutexes, fences, barriers, etc.

  • @Kitulous
    @Kitulous 2 місяці тому +1

    awesome content.
    btw, I can't tell if it's your narration or AI

  • @tomascoelhopinto
    @tomascoelhopinto 2 місяці тому +1

    this channel is pure gold

  • @user-qr4jf4tv2x
    @user-qr4jf4tv2x 2 місяці тому +1

    this is the kind of video you want to watch instead of playing in background
    no pun intended

  • @madlep
    @madlep 2 місяці тому

    Could do another video on mutable shared state concurrency with threads, but Halloween was a month ago 😱.
    Great vid though 25 years working in the industry as a software engineer, and I still learn new details from these videos.

  • @王特-p4j
    @王特-p4j 2 місяці тому

    Unbelievable that this amazing channel has only 160,000 subscribers!

  • @ILightWas
    @ILightWas Місяць тому

    I would love to learn more about the mechanisms in hardware related to synchronization. I have coded in C++ and understand how to use a mutex, but understanding how it works in detail and how that relates to the hardware is a different matter

  • @pranavasubhat7430
    @pranavasubhat7430 29 днів тому

    One of the best channels I have come across so far..

  • @gustavofigueiredo280
    @gustavofigueiredo280 19 днів тому

    Só much easier to understwnd now. Thanks for the vídeo !

  • @wm6126
    @wm6126 Місяць тому

    As a self-taught guy constantly getting belittled, I enjoy learning from your channel as well as lowlevel.

  • @SatyajitRoy2048
    @SatyajitRoy2048 Місяць тому

    Parallelism with multi cores would be really fascinating to watch. Great visual representation.

  • @Dominik-K
    @Dominik-K 2 місяці тому

    Great video, very well explained

  • @akashsonar6332
    @akashsonar6332 2 місяці тому

    This is the first time that i really understand what and why are Threads.

  • @shafqatarefiin7727
    @shafqatarefiin7727 2 місяці тому

    U got a sub and new fan🎁, loved the topic ❤️

  • @bigbtripathi
    @bigbtripathi 2 місяці тому

    Wonderful video. This kind of videos should be shown in CS classes.

  • @wasordx3245
    @wasordx3245 Місяць тому

    Nice videos id love to see you explain how peripheral devices drivers etc and the internet works on the hardware level

  • @Newb1eProgrammer
    @Newb1eProgrammer 2 місяці тому +8

    Woah man, this is peak content on youtube. Programming in python as a kid left me thinking that threads are free parallel execution (only somewhat correct) and used them for whatever I wanted without knowing what they are actually for (this caused problems). Now thanks to this video, I know how it is actually operated. And just as a sidenote, I actually found out that variables are stored in the thing programmers call the stack from when you brought it up in this video, im not in college yet and am trying to learn computer architecture so this entire video was huge for me, as with all your videos. Insanely great.

  • @blaiseduncan1160
    @blaiseduncan1160 2 місяці тому

    Bro you deserve 1mil subs the content is so fire

  • @pablote325
    @pablote325 Місяць тому

    This is incredible. Thank you very much!!!!!

  • @AnantaAkash.Podder
    @AnantaAkash.Podder 2 місяці тому

    Badly waiting for the NEXT One... with Multiple Core & Parallelism ❤️❤️