How CPUs Use Multiple Cores

Sdílet
Vložit
  • čas přidán 10. 06. 2024
  • Check out the new Logitech MX Anywhere 3S Mouse and MX Keys S wireless keyboard at Best Buy through the links below. Save 20% with purchase of a computer, laptop, monitor or tablet. Offer ends June 30th.
    Logitech MX Anywhere 3S Mouse at Best Buy: lmg.gg/MXANYWHERE3SBB
    Logitech MX Keys S at Best Buy: lmg.gg/MXKEYSSBB
    Purchases made through some store links may provide some compensation to Linus Media Group.
    Learn how CPU scheduling works and it helps them juggle multiple tasks and use multiple cores.
    Leave a reply with your requests for future episodes.
    ► GET MERCH: lttstore.com
    ► LTX 2023 TICKETS AVAILABLE NOW: lmg.gg/ltx23
    ► GET EXCLUSIVE CONTENT ON FLOATPLANE: lmg.gg/lttfloatplane
    ► SPONSORS, AFFILIATES, AND PARTNERS: lmg.gg/partners
    FOLLOW US ELSEWHERE
    ---------------------------------------------------
    Twitter: / linustech
    Facebook: / linustech
    Instagram: / linustech
    TikTok: / linustech
    Twitch: / linustech
  • Věda a technologie

Komentáře • 525

  • @VanillaSpooks
    @VanillaSpooks Před 11 měsíci +1275

    I'm now going to have nightmares about a CPU with eyes and a mouth...

  • @tannerted
    @tannerted Před 11 měsíci +514

    I appreciate the explanation you have put together! Quick nit-pick: "Context Switching" is NOT when a process is moved between cores. Schedulers WILL try to avoid moving processes to different cores, but for a different reason (to lower the CPU cache miss rate for said processes). Context switching is when the OS changes which process is running on a given core. Multiple processes will be running on the same core; a context switch is when the OS switches between processes running on the same core. Context switching isn't free (in terms of CPU time/performance), so you are correct in saying that the OS tries to avoid context switching too much. Context switching is necessary to keep all processes responsive as there are often hundreds of processes each vying for CPU time.

    • @luizgustavomarques8935
      @luizgustavomarques8935 Před 11 měsíci +41

      Was looking for this reply or going to do it myself

    • @andrebrait
      @andrebrait Před 11 měsíci +20

      ​@@luizgustavomarques8935same. I literally paused the video to check whether someone had already written that.

    • @rohansampat1995
      @rohansampat1995 Před 11 měsíci +12

      WAS about to write this, but you got it. Lol. This video is not the most accurate on the finer points.

    • @luizgustavomarques8935
      @luizgustavomarques8935 Před 11 měsíci +9

      @@rohansampat1995 yeah, this is a bit bellow usual quality of information
      Was expecting then talking program counters at least.

    • @ChristopherHailey
      @ChristopherHailey Před 11 měsíci +8

      I just said the same thing before I noticed you posted what i said. You are correct. I think process threads and multithreaded processors are getting confused as well

  • @HeisenbergFam
    @HeisenbergFam Před 11 měsíci +417

    "If I tell you im multitasking, dont believe me"
    Even if Linus is not multitasking always make sure to supervise him while he holds stuff

    • @shivalah
      @shivalah Před 11 měsíci +18

      Talking and holding are two different things, that's proof Linus cannot multitask and why this is Linus Drop Tips.

    • @dinozaurpickupline4221
      @dinozaurpickupline4221 Před 11 měsíci

      He eats CPU for breakfast
      & Then poops multitasking

    • @lordfalke8117
      @lordfalke8117 Před 11 měsíci

      Hello there

    • @extremepsykosis
      @extremepsykosis Před 11 měsíci

      I let him hold my newborn once... :D

  • @negativepremium4100
    @negativepremium4100 Před 11 měsíci +66

    are we just going to ignore how cursed these animations are ?

    • @EveningOfficer
      @EveningOfficer Před 11 měsíci +2

      Yes, we are.
      *Don’t make me think about them* 😖

    • @YounesLayachi
      @YounesLayachi Před 11 měsíci

      And the dreaded loading animation with spinning dots , why...
      Anyone who spent any time with technology will absolutely hate seeing that animation on screen

    • @pols-czproduction2609
      @pols-czproduction2609 Před měsícem

      I have severe headache trying to understand how that engine works.

  • @necruo7724
    @necruo7724 Před 11 měsíci +47

    the animations are nightmare fuel, keep up the stellar job guys :)

  • @dampfwatze
    @dampfwatze Před 11 měsíci +42

    2:59 Content Switching actually means to interrupt one thread, saving it's context/state, loading the context of another thread and start running it. This all happens on one core and hasn't anything to do with switching the core it is running on. Although this is the mechanism, that might lead to switching the core, a thread is running on.

    • @rohansampat1995
      @rohansampat1995 Před 11 měsíci

      I dont think the scheduler generates an interrupt but yes. Note interrupts usually are handled through processing of an interrupt queue

    • @dampfwatze
      @dampfwatze Před 11 měsíci +4

      @@rohansampat1995 I wasn't really referring to the interrupt system, I just meant the concept of interrupting something running. It is up to the implementation, how this is done.

    • @ailivac
      @ailivac Před 11 měsíci +1

      And "quickly switching my attention from one thing to another" IS fundamentally how every multitasking OS works. It's just that on an SMP system you have multiple processors each doing that at the same time.

    • @rohansampat1995
      @rohansampat1995 Před 11 měsíci +1

      @@ailivac exactly they got it wrong in the first 30 seconds. new record for the channel.

  • @jimflagg4009
    @jimflagg4009 Před 11 měsíci +356

    As a programmer I can tell you multi-threaded programming is hard. You have to make sure your memory variable and other objects are thread safe. That is that more than one thread is not accessing the same variable at the same time. Even then it can make your program unsafe because if one thread fails it need to let the task being done on the other thread know. I some times make workers which work as independent programs and chunk out my tasks. Yes this is not real threading but it is more stable.

    • @hahasamian8010
      @hahasamian8010 Před 11 měsíci +4

      Edit: Thanks for clarifying the specifics for me guys ✨️ Guess I wasn't exactly right-
      Wasn't the PS3 one of the first consumer multi-core computers? I think this was why it was difficult for devs to work with, usually resulting in worse ports, but ending up with some superior titles towards the end of life.

    • @Youwotm8Tk
      @Youwotm8Tk Před 11 měsíci +29

      @@hahasamian8010 No, it wasn't the first multi-core/multi-thread processor. In fact the Xbox 360 had 6 threads and the PS3 had 2. The reason it was so hard to program was because it had a really weird/unusual hardware architecture.

    • @jimflagg4009
      @jimflagg4009 Před 11 měsíci +6

      @@hahasamian8010 Main Frames or Mini Computers were "multi core" in that they were multi-CPU. Cores came around the early 2000s with the IBM Power4 computers but they could only run Unix and I think some Linux distros no Micro code for other OSs. The first PC CPU I think was Pentium D duo even though there were multi threaded single cores before this.

    • @GSBarlev
      @GSBarlev Před 11 měsíci +10

      Chunking out tasks into individual programs is *exactly* how to get the most out of multicore 90% of the time, especially since it ends up allowing you to scale to distributed systems.
      Even within a single application, structuring your tasks into concurrent futures is way less of a headache than managing synchronous communication between threads.

    • @codyrap95
      @codyrap95 Před 11 měsíci +1

      ​@@Youwotm8TkSo PowerPC is unusual/weird architecture to you? A lot of companies including Apple were able to make it work, it's just that people weren't used to thinking and programming in the way that PowerPC required

  • @notenoughmonkeys
    @notenoughmonkeys Před 11 měsíci +41

    I thinik of it in terms of CZcams channels. High priority - LTT, Medium Priority - TechLinked, Low Priority - TechQuickie, Zero Priority - Channel Super Fun. And if you want an example of setting a priority too low and seeing how it impacts scheduling, just look at when WAN starts each week.

    • @drk_blood
      @drk_blood Před 11 měsíci +2

      More like LTT and TechQuickie - High, ShortCircuit and the incoming GameLinked - Medium, and CSF and TechLinked - LOW :p

  • @jwlee21
    @jwlee21 Před 11 měsíci +41

    I think the context switching analogy given is a bit off… it’s not threads going from core to core per se, it’s which thread is active on a core. And since typically there are more threads running than there are cores on a CPU, the OS has threads that are actively being worked on and others that are not. When a thread that is not active becomes active, then that’s a context switch… the problem with context switches is that it takes time to make that switch which may be a minuscule amount of time. However the problem becomes if too many of these context switches start occurring, then performance starts becoming degraded.

    • @noergelstein
      @noergelstein Před 11 měsíci +1

      A context switch is simply the CPU (either real or Hyperthreading core) switching from one thread to another or to an operating system context (for example for file handling, networking etc.). A lot of what makes modern CPUs fast (pipelines and caches have to be flushed, branch predictor might need to relearn the context) does not work across the context switch boundary (for among others also for security reasons). It is like the CPU having to drive to the pitstop, come to a full stop, then later accelerate again. For consumer systems you want frequent switches to make sure that there is never any stutter and for example audio output has no interruptions. For high performance computing where interactivity is non-existant, you might want to lower the switching frequency.

    • @insu_na
      @insu_na Před 11 měsíci +1

      The problem is that with a context switch the L1 and sometimes L2 caches need to be invalidated and receive new Data from hopefully L3, suboptimally RAM and awfully a block device. Pushing new data into the caches takes time and needs to happen every time a thread changes.

    • @ShinyQuagsire
      @ShinyQuagsire Před 11 měsíci

      yeah a context switch happens every time when you move from userland to kernel, or kernel to hypervisor (or userland to hypervisor), ie during a syscall or due to a timer interrupt. It's also why ~most hypervisors are slow AF on virtualized MMIO compared to direct memory mappings, because what used to be a 1 cycle write now requires 100+ cycles of saving/loading registers, possible cache misses, etc and it adds up fast.
      Moving a thread between cores is called thread migration/core migration, and is expensive because it means it has to flush the caches to memory on the old core and invalidate caches on the new core.

  • @shapelessed
    @shapelessed Před 11 měsíci +24

    Pretty sure context switching is not the process of juggling a thread between cores, but juggling between multiple threads on a single core.
    It's the core that's switching context, not the thread.

  • @SingleRacerSVR
    @SingleRacerSVR Před 11 měsíci +60

    Video Suggestion :- One thing I notice on lots of your video's, is your team discussing complex hardware & software details in a way us less experienced users can understand. But as a much older person that came from the "DOS ERA", where it was almost common say, to have things like "bad sectors" on mechanical hard-drives. And you just had to except this as a fact of life. One thing that blows me away therefore is today's tech reliability. My last 3 PC's for example ran without fault (baring a software glitch, that I usually created) for 5-7 years without any drama. So could you do a video on your thoughts as to why you think that given the complexity of say CPU & GPU instructions for example - why are computers & phones still (generally) so stable & reliable these days, given that complexity?

    • @ShinyQuagsire
      @ShinyQuagsire Před 11 měsíci +11

      Virtual memory and Windows Vista, and I'm not even kidding. Every memory safety feature that Vista added caused a lot of instability in the *short term*, but dramatically increased code quality and reliability in the long term. Before ASLR, libraries would all often be clustered around the same addresses, so accidentally corrupting a pointer or going out of bounds meant you would sometimes hit a valid address and the program would continue running (the consequence being, you just barfed on unrelated memory and have no idea where or how). With Vista and ASLR, every library is extremely far apart, so simple mistakes are no longer tolerated, but it also means simple mistakes are caught easily and early.

    • @SingleRacerSVR
      @SingleRacerSVR Před 11 měsíci +8

      Fantastic replies user-rh7 & Shiny. I consider myself an abOve average user - but only because I am always open to listening to what more advanced users like yourselves have to add to my own lack of knowledge. Hence why I am subscribed to LTT. Thanks for you comments ; )

    • @psoltan
      @psoltan Před 11 měsíci +1

      I've been working with computers since the IMSAI 8080. I don't know who you are shilling for but computers are LESS stable now than they were 20 years ago. Bad sectors on a disk have nothing to do with intrinsic stability. That was just from manufacturing problems.
      Try not rebooting your computer or your phone for weeks and then tell me about stability. Software and hardware are much more complex now and testing, at least for software, hasn't kept up. Very smart people write the OS critical code and memory garbage collection hides many problems with less proficient coders.
      I dread every Windows update because something new will break and I'm not even trying to find problems. Open-source software is the only thing keeping the world from a complete software disaster. Paid programmers are always under pressure to finish sooner rather than write better software. Software only has to be "good enough" and sometimes it's not actually very good at all.
      If you were not shilling for someone, you would notice that computer hackers cost the economy trillions of dollars every year. Some of this is due to human gullibility but much of it is due to a lack of focus on security when writing software. So when you say that "computers and phones are still generally so stable and reliable these days" it makes you sound clueless.

    • @kumquat19138
      @kumquat19138 Před 11 měsíci

      @@psoltandaddy chill

    • @SupaKoopaTroopa64
      @SupaKoopaTroopa64 Před 11 měsíci +1

      @@psoltan You've got a good point about open-source software. Aside from some games and productivity software, the only proprietary software on my system is the Nvidia drivers, and I bet you can guess what interrupts months of up-time. 99% of the time I restart my computer is because cuda stops working for some unknown reason.

  • @laughingseal007
    @laughingseal007 Před 11 měsíci +12

    I love me some Fast As Techquicke

  • @benjaminclehmann
    @benjaminclehmann Před 11 měsíci +32

    Context switching isn't moving a thread to a new core. It's pausing a thread and running a different one on that core.
    A scheduler will occasionally pause a thread and resume it immediately on a different core (e.g. promoting from E core to P core because it needs more juice), but most context switches are pausing a thread to be resumed later, and usually on the same core that it was already running on.
    In addition, the idea of computer multitasking as starting, stopping, and restarting multiple tasks is not a misconception, it's really actually quite apt and that is the main purpose of scheduling. You have hundreds of processes with thousands of threads running at one time. You probably have 8 cores or less. It is nowhere near possible to run all of them simultaneously. Fortunately for you, most threads need a CPU core only for a small burst, then they need to wait for something like RAM, or disk, or the network, or another core, or the user. While this thread is waiting a different one can be scheduled. The best analogy is that processors multitask exactly how we do, we just have multiple processors in a computer, which allows simultaneous multiprocessing. And then you have that one of these processors is the boss (scheduler) who spends some of their time deciding who ought to do which tasks in which order, though most of their time is still spent doing normal work.
    Of course you can complicate this with hyperthreading, pipelining, and VLIW which arguably provide "real" multitasking on a single CPU, but for a healthy understanding it's enough to say that 1 thread per core, this thread will run for a very short amount of time (say 10 milliseconds) before it is replaced by a different thread. This understanding is sufficient for many purposes primarily because computers mimic old computers and so this is what (most) software assumes. And arguably is what it ought to assume so that the scheduler can expose this facade leaving the complexity to itself for it alone to handle and optimize.

  • @oso3557
    @oso3557 Před 11 měsíci +30

    Actually Humans are great at multithreading.
    Many background tasks like object recognition, eye-movement, hand coordination and much more is handled by specifically designed parts of the brain. Similar to accelerators in a CPU.
    Or listening to an audiobook while driving, cooking and talking (if possible) and many other examples of human multitasking.
    Only becomes problematic when two two tasks try to access the same brain area at once. It's impossible to listen to two people at once, or reading while having a conversation.
    Also human main task scheduling depends immensely on person and sex.
    Additionally similar to Task priority on CPUs and Windows, humans have the ability to focus on specfic tasks, reducing and limiting all other not mandatory processes

    • @ninjadev64
      @ninjadev64 Před 11 měsíci +1

      Sex*, not gender.

    • @flameshana9
      @flameshana9 Před 11 měsíci +1

      A computer can have millions of conversations at the same time whereas we're stuck with just one. That's what multitasking means. An actual thing that requires attention. Unconscious things don't really count in most cases.
      I can walk and talk but I can't talk and talk. Heck, most people can't even think and talk.

    • @oso3557
      @oso3557 Před 11 měsíci +1

      ​@@flameshana9 I mean, running background tasks is the majority the cpu and OS have to schedule. Especially on windows with often 100-200 background tasks.
      But yeah, I agree, that humans don't have "general purpose" elements like CPUs and can only "multithread" as long it's on separate parts of the brain.
      Although scheduling on the same part of the brain can work for some people.

    • @oso3557
      @oso3557 Před 11 měsíci

      @@ninjadev64 thanks

    • @Forty2de
      @Forty2de Před 11 měsíci +1

      you're saying I'm supposed to be able to breathe and beat my heart at the same time?? That sounds pretty difficult

  • @insu_na
    @insu_na Před 11 měsíci +65

    I would've appreciated it if you went more into the side of Linux scheduling. There are so many different, interesting schedulers. CFS being the default Linux scheduler, MuQSS being an interactivity focused scheduler written by Con Kolivas, PDS being a gaming-focused (more or less) scheduler written by Alfred Chen, BMQ, Cacule, etc. etc.
    All of them have unique and interesting approaches to this task and all of them are interesting

    • @GSBarlev
      @GSBarlev Před 11 měsíci +15

      Probably too technical for the Techquickie audience, but I'd love to see, say, Brodie Robertson do a deep dive.

    • @ChristopherHailey
      @ChristopherHailey Před 11 měsíci +5

      I think that's way too tired technical for this channel and would be a much longer topic (many hours)

    • @loc4725
      @loc4725 Před 11 měsíci +1

      ​@@GSBarlevAn in depth dive would be more of a DMWare thing.

    • @neiljp-dev
      @neiljp-dev Před 11 měsíci +6

      I agree that noting alternative scheduling approaches exist would be preferable, and disagree with other comments that it would necessarily need to be more technical. Pointing out that different operating systems do vary in how they do it by default (rather than just 'Windows does x') and why those are relevant would be informative - particularly given the gaming audience LMG typically attracts.

    • @ChristopherHailey
      @ChristopherHailey Před 11 měsíci

      @@neiljp-dev That's a good point, I think that's where people have an interest here, how does gaming leverage multiple cores. It's really evolving, most games don't handle it well. I remember getting my first hyperthreaded CPU way back when, it had 1 core with 2 threads and the improvement was vast, games would not glitch due to backup processes, one thread would be the game and the other used by background processes...like anything now it's more complex. Just that topic would be a good video.

  • @Eli-zb2yj
    @Eli-zb2yj Před 11 měsíci +10

    I never use gpu and cpu. I just put a lot of rgb on my printer, and that's enough

  • @QueenSaffryn
    @QueenSaffryn Před 11 měsíci +4

    I can't wait for the next Fast As Techquickie video :)

  • @savagepro9060
    @savagepro9060 Před 11 měsíci +14

    Linus: How CPUs Use Multiple Cores?
    Single Cores:

  • @Xpurple
    @Xpurple Před 11 měsíci +24

    It's a lot better than it was 20 years ago. The systems we used then for SMP scheduling where "less than optimal".

    • @wertywerrtyson5529
      @wertywerrtyson5529 Před 11 měsíci +3

      It’s still amazing that you could do so much with just one thread back then. Back in the early 2000s I never thought we would get multi core CPUs. But if you had told me that 20 years later we would still be at only about 5ghz I would have laughed and said that in 20 years surely we would have 1thz CPUs or 100ghz at least. My computer from 2003 after all had 10x the mhz of my PC from 5 years earlier.

    • @Xpurple
      @Xpurple Před 11 měsíci +2

      @@wertywerrtyson5529 : I was using multi processor sparcstations at that time. Pretty powerful machines back then.

    • @GSBarlev
      @GSBarlev Před 11 měsíci +2

      The fascinating thing is that (20 years ago at least), whereas shared-memory multithreading was still going through growing pains, *distributed computing* (running massive tasks on clusters of dozens or thousands of machines) was extremely mature, with a lot of the theory having been developed when "computers" had names like Katherine and Dorothy.

    • @Xpurple
      @Xpurple Před 11 měsíci +1

      @@GSBarlev : Yep. Great for tasks that can be split up easily.

  • @clayton_games
    @clayton_games Před 11 měsíci +1

    I like how he almost went into his "fast as possible" ending and corrected himself to techquickie.

  • @LarkyLuna
    @LarkyLuna Před 11 měsíci +2

    Context switching refers to a single core storing a thread and starting another, not the reassignment of cores
    Affinity handles the process of preferring to resume threads on the same core

  • @ethanberg3343
    @ethanberg3343 Před 11 měsíci +2

    Wow I forgot that these TechQuickie videos used to be titled "As Fast as Possible." Linus had to catch himself there.

  • @MarioGoatse
    @MarioGoatse Před 11 měsíci +3

    I love that you’re hiring teenagers proficient in MS Paint to edit your videos. Really gives it that “old school CZcams feel”.

  • @somestarwarsnerd9068
    @somestarwarsnerd9068 Před 11 měsíci +6

    Great video, but context switching is more complicated than that. It also happens if the core doesn't change, but when an interrupt causes something else to be executed

    • @mozzjones6943
      @mozzjones6943 Před 11 měsíci

      Welcome to Tech "quickie" ?

    • @ChristopherHailey
      @ChristopherHailey Před 11 měsíci +3

      Actually the whole context switching part was wrong and should be discounted. Some of the other info was ok but quite a bit was "sortta". Not one of the more accurate clips. I think it's a glitch in the video that is problematic, but most of the rest is OK. It's a very complex topic and very difficult to explain in a simplified way.

    • @mozzjones6943
      @mozzjones6943 Před 11 měsíci

      @@ChristopherHailey Intel employees need firing? Cause that's where the info for this video came from lol

    • @ChristopherHailey
      @ChristopherHailey Před 11 měsíci +1

      @@mozzjones6943 You ever play "the telephone game"? The first person says something an then it gets mangled as it goes down the line? Well I got my info from my CS degree and experience not from CZcams (sorry about the flex). If you look there are lots of comments saying the same thing and lots of helpful replies. Most of the video is correct but there are a few "yeah, buts" which are being discussed nicely. I think a few things could have been explained better and the comments are helping, so the system works

    • @unocualqu1era
      @unocualqu1era Před 11 měsíci +1

      @@ChristopherHailey Linus Sorta Accurate Tips

  • @sviffls1833
    @sviffls1833 Před 11 měsíci +8

    Great video as always but I think you guys misunderstood context switching(3:02). As I learned it context switching is when a core changes perimission levels from for example kernel to user. These contexts are how the cpu knows what parts of memory a thread is allowed to read from and write to so that not every program can just go and change important data

    • @BrianG61UK
      @BrianG61UK Před 11 měsíci +1

      Context switching is when a core changes from doing one thing (running one thread) to doing another thing (running a different thread). It's slow because all the context (register and flag values etc. in the core) need to be saved to RAM and a new set loaded from RAM. And yes, it's potentially even slower when also changing from, say, kernel space to user space.

    • @fugoogle_was_already_taken
      @fugoogle_was_already_taken Před 11 měsíci

      No, full context switch is, as OP said, when CPU has to change operation mode from privilaged to unpriviliged (and viceversa), so when jumping between user and kernel space.

  • @bacon.cheesecake
    @bacon.cheesecake Před 11 měsíci +1

    1:44 "As the OS can use QOS to request"
    Linus spitting bars

  • @alexferguson5346
    @alexferguson5346 Před 11 měsíci +2

    Those animations are going to haunt my nightmares

  • @ThunderBlastvideo
    @ThunderBlastvideo Před 11 měsíci

    ive ALWAYS wanted to know this! thanks!

  • @kiosfriend
    @kiosfriend Před 11 měsíci +2

    "for a future fast....techquickie" I see what you almost said there ;)

  • @StuckOnAFireHydrant
    @StuckOnAFireHydrant Před 11 měsíci +1

    Took a whole class on this, yet here i am watching again just cause i enjoy these tech quickies. A couple inaccuracies, but very good for just the technology curious people out there.

  • @OldGamerNoob
    @OldGamerNoob Před 11 měsíci

    I want to see the out-of-order processing on multi-core processors be able to take advantage of resources on dormant cores, kind of similar to how the hyper-threaded cores will use dormant resources on their own cores for a second thread (only kind of backward)

  • @alexlandherr
    @alexlandherr Před 11 měsíci

    This explanation touches on what I learned with the “std::thread::hardware_concurrency()” method and threads in C++; threads can behave almost like *truly* parallel processes but aren’t really that. For true parallelism you’d need platform-specific libraries.
    And not all CPUs support “hyper-threading”-like technology so on a Raspberry Pi 4B “std::thread::hardware_concurrency()” returns the physical core count of 4 cores.
    On my i7-12700H Linux laptop I get 20 concurrent threads from “std::thread::hardware_concurrency()” which is awesome for stuff that needs it like searching for primes which I wrote a program for in C++ to learn about this very topic.

  • @MikeHarris1984
    @MikeHarris1984 Před 11 měsíci +2

    00:45 this is the GloryThread

  • @satrioadi7044
    @satrioadi7044 Před 11 měsíci +1

    I did not need to see an image of CPU with animated eyes and a gaping hole for mouth this early in the morning yet here I am

  • @commandurrazor
    @commandurrazor Před 11 měsíci

    Hey for a future episode (or maybe something to test at labs) can you make a "final" showdown of round vs flat ethernet cables? I keep seeing "they're worse for performance and interference" but other people saying the interference isn't really a problem for home network settings so I'm not sure what to think..

  • @ari-mcbrown
    @ari-mcbrown Před 11 měsíci +1

    Correction: context switching happens when processes are being picked up by the OS to delegate to a CPU... Context switching was already a thing with single core CPU's. This is how an OS handles multiple tasks at once.

  • @r.g7261
    @r.g7261 Před 11 měsíci +1

    Me: you can't just explain an entire engineering semester's worth of content in 5 minutes
    Linus: Hold my tips

  • @johndoh5182
    @johndoh5182 Před 11 měsíci +1

    Context switching is used when one thread hits a wait state, or if you have lots of tasks to run but very few cores and you get a backup of high priority threads and a low priority thread is running. This typically happens when resources are needed. IF a thread has to wait AND the system needs to run something that has a higher priority THEN you get into context switch. It is NOT simply to switch a thread to a different core, that's like the worst thing a CPU could possibly do because context switching takes many clock cycles. It stores the register values, and other information to run the thread including the code to DRAM, and then the core loads what is needed to run a higher priority thread.
    Next, I didn't understand most that last part after context switching and I've been working with hardware and software for 40 years now. A programmer, to use many cores has to write the program to use many threads. I don't know every language that exists but many require you to spawn new threads, by writing code. I'm not quite sure how libraries fit into this, but libraries can mean more than one thing. A programming language can have built in libraries so a programmer can write code much easier, and spawning a new thread would be a function that's built into the library for a language. But that doesn't sit anywhere except in the program that was written. If I write a program in C++, the executable will contain the code I wrote, and that will include the sections of the library that the code needs because I called a function in the library. So there is no magical library just floating around, and even when I write a program and then compile it, it's typically a small amount of the programming language library that ends up in my code.
    Load balancing is something the scheduler can do on it's own, but it has to be working with many threads before it's going to deal with load balancing. Or, there are times when the CPU can switch a thread that's been running on a core for a long time over to another core. THIS is a load balancing process. Spreading threads around to available cores is a normal function of the scheduler and this has nothing to do with programs a coder writes. This is a function of the OS scheduler.
    So, it can be confusing when you start mixing up the OS with programs the OS is dealing with. It's ALL code that programmers wrote including the scheduler, but when you're talking about load balancing that's more a function of the scheduler and nothing else. When the system is running very few threads it's very simple for the scheduler to simply throw a thread at any available core and rotate threads through all the cores so that no core is doing too much while most cores are idle. When running heavier loads it's still the same thing, the scheduler will throw threads at different cores based on what's available and the load gets balanced with very little effort. A person writing a program doesn't need to worry about this. The only thing they need to worry about is if their app will be more efficient and faster if it's broken up into multiple threads, and programs that run in a very linear way, meaning there is almost nothing you can do in parallel shouldn't be broken up into multiple threads because it takes LONGER to do this.

  • @laszloperneky8417
    @laszloperneky8417 Před 11 měsíci +1

    At 0:49 we see the future. Programmers just having a conversation about what will be for dinner, while the code just writes itself :D

  • @eshakrafi5797
    @eshakrafi5797 Před 11 měsíci

    Your explanation was very good ❤

  • @EnbyCatboyGF
    @EnbyCatboyGF Před 11 měsíci +3

    I think a great Techquickie would be an explanation about what source code is, while people may have a broad idea about what it is but i feel like not a lot of people know why it's so irreplaceable when it comes to remastering their favorite game.

  • @jason6618
    @jason6618 Před 11 měsíci +2

    Best buy sponsor. Did not expect that.

  • @DatBoiTip
    @DatBoiTip Před 11 měsíci +1

    video idea: can you explain the difference between the different use cases of gpu (work station , gaming ,telsea ect.)

  • @SDRIFTERAbdlmounaim
    @SDRIFTERAbdlmounaim Před 11 měsíci +2

    when a cpu can Schedule millions of threads and i a mere human can't properly schedule between my studies and gaming 😂

  • @oksowhat
    @oksowhat Před 11 měsíci +1

    there are also other type of scheduling, not only priority, like round robin and SJF.

    • @ChristopherHailey
      @ChristopherHailey Před 11 měsíci

      I took an entire CS course in scheduling, it's a big topic

  • @jtmcdole
    @jtmcdole Před 11 měsíci +1

    That chip animation is nightmare fuel.

  • @nclark5720
    @nclark5720 Před 11 měsíci

    sponsor was a good one!!!! i personally have an MX anywhere 2, it's awesome for me because i play all games using a gamepad from my couch. this mouse works on any surface so i can use it anywhere

  • @Random_dud31
    @Random_dud31 Před 11 měsíci +1

    Its still hard to believe that in the end, its all just 0s and 1s

  • @MetalMan1245
    @MetalMan1245 Před 11 měsíci

    I love how they just inexplicably used the Tea cooled PC as a demonstration for no particular reason and I love it.

  • @milind8751
    @milind8751 Před 11 měsíci

    Correct me if I'm wrong but isn't context switching the process of saving/restoring the state of a process/thread so that it can be paused or later resumed?

  • @SupaaMann
    @SupaaMann Před 11 měsíci +1

    Techquickie as fast as possible would be a fun April fools kind of video

  • @joshuastanlick6217
    @joshuastanlick6217 Před 6 měsíci +1

    I just run everything real-time priority on a 13900KS. Ultimate Performance with core-parking fully enabled. I just play games, and although the PC is not useable during benchmarks like R23 or Passmark, once they complete, the scores increase significantly and everyday use like gaming has the absolute lowest delta for processing. Running everything real-time priority on a computer whose 32 threads are rarely saturated is just fine and almost 100% harmless, for a noticeable improvement in performance that I'd say is even better than what a hefty overclock would grant on its own. I run my 13900KS stock save for Re-BAR and XMP in BIOS. I use Process Lasso for the priorities, CPU sets, and CPU affinities. I didn't touch the actual Windows Scheduler at all.

  • @addledhead
    @addledhead Před 11 měsíci

    It's like they were trying to animate "It's so bad it's good" but stopped halfway

  • @squirtle88
    @squirtle88 Před 11 měsíci

    more videos like this please

  • @bogata903
    @bogata903 Před 11 měsíci +1

    You never talked about what a interrupt is... That would have been a nice thing to add in...

  • @Shini1171
    @Shini1171 Před 11 měsíci

    Right before my CPU finals. cheers!

  • @stalememe3305
    @stalememe3305 Před 11 měsíci +2

    That CPU with eyes is REALLY uncanny who made this!?

  • @PanchoMngkn
    @PanchoMngkn Před 11 měsíci

    Thank you for your videos Linus ❤

  • @kipchickensout
    @kipchickensout Před 11 měsíci +1

    As a developer, I can confirm 0:50 is exactly how I write my code

  • @usopenplayer
    @usopenplayer Před 11 měsíci

    Multitasking: it's actually like what humans do, switching from one task to another. But really only working on one thing at a time.
    Parallel programming: doing multiple things on different cores.
    Threads: a group of instructions that the scheduler can juggle for multitasking or execute in parallel, depending on the code.
    Context switch: when you are switching tasks, I usually see it referred to switching between OS library and regular applications. Could be same core or different core.

  • @doctor_gee
    @doctor_gee Před 11 měsíci +1

    I look in task manager and see I'm running 3200 threads with barely anything running. How Windows juggles those threads between my 8 (16) CPU cores is pretty amazing.

  • @glados_creator
    @glados_creator Před 11 měsíci +1

    are we sure on the definition of context switching ? because for me it is changing between threads on a single core so restoring registers , the stack and code

    • @glados_creator
      @glados_creator Před 11 měsíci

      what is even more expensive and what is demonstrated is changing the core of a thread so coping it's state and code and yeah memory transfers are slow

  • @Goodsdogs
    @Goodsdogs Před 11 měsíci

    On the up coming gaming channel you guys should have a video series on how to play: anno 1800 , and etc how to play/start osrs , how to game : mmorpgs , how to game rts’s , how to game puzzle games and which ones are great for beginners to masters

    • @Goodsdogs
      @Goodsdogs Před 11 měsíci

      I don’t have any experience being a video writer but I do have editing and lots of ideas 😂

  • @wassimajili5983
    @wassimajili5983 Před 11 měsíci +1

    We can see linus in more videos now, the new CEO is the best thing that has happened to LTT since forever

  • @hanswurst9120
    @hanswurst9120 Před 11 měsíci +1

    Shoutouts to Ben Benson at Intel for having very creative parents.

  • @SAl-sg8gt
    @SAl-sg8gt Před 10 měsíci

    where was this videos 4 years ago when i was "learning" data structures class

  • @jedward3282
    @jedward3282 Před 11 měsíci +1

    Isn't the scheduler doing tasks one at a time? So is there any real multitasking going on?

  • @sam19953
    @sam19953 Před 11 měsíci +1

    Damn, (Embedded Linux) Scheduling will be a topic of my exam next week amongst many other things.

  • @jamtea388
    @jamtea388 Před 11 měsíci

    Thanks for this video!
    For whoever is doing the canned content inserts, I think it is nicer to just look at the speakers face.

  • @ayaanbari6711
    @ayaanbari6711 Před 11 měsíci

    He explained what I read before my COA exam in just 5 mins wow🙂

  • @srobak
    @srobak Před 11 měsíci

    the graphics and animations on this one are frakkin hysterical...

  • @arunnaik622
    @arunnaik622 Před 11 měsíci

    I have operating system exam tomorrow and I just opened utube search this topic and your video in my recommendation

  • @Jon717
    @Jon717 Před 11 měsíci

    3:59 The Spiffing Brit build

  • @owenarnold8117
    @owenarnold8117 Před 11 měsíci +1

    Very good vid!

  • @monoklmen
    @monoklmen Před 11 měsíci

    25 seconds in and I am already smashin the like button. What a goofy CPU avatar, love it.

  • @hovant6666
    @hovant6666 Před 11 měsíci +1

    those were some creepy animations m8

  • @AutumnRain
    @AutumnRain Před 11 měsíci +2

    not too found of their eyes and mouths but i'm not gonna make fun of CPUs too much. they get the job done

  • @bgezal
    @bgezal Před 11 měsíci

    CPU context switching is like changing the load in your washing machine mid laundry.

  • @CMDR_John_Crichton
    @CMDR_John_Crichton Před 11 měsíci

    3:16 Are we just not going to talk about how each of the pistons in the engine animation are going in opposite directions?

  • @_shadow_1
    @_shadow_1 Před 11 měsíci

    Now I just need to figure out how to run multiple processes and prioritize things in my brain without unknowingly hitting my power limit then crashing.

  • @adsy6819
    @adsy6819 Před 11 měsíci +1

    I can multitask, I’m pooping and watching this video at the same time.

  • @m.anejante1687
    @m.anejante1687 Před 11 měsíci

    why that crankshaft has some rods circling one way and others in the opposite? is that some kind of new magical crankshaft?

  • @SneakyJoeRu
    @SneakyJoeRu Před 11 měsíci

    Start of the video sound is screwed

  • @shanent5793
    @shanent5793 Před 11 měsíci

    Single cœur systèmes could also multitask, so how did they do that without context switching ?

  • @pgplaysvidya
    @pgplaysvidya Před 11 měsíci +1

    i've been dinking around with priority and affinity, etc trying to get starcraft 2, a highly cpu intensive game that uses i dunno how many cores (4? 8? 2?) regardless of cpu horsepower. it seems to work best if i set the game to be in real time priority with 8 or so threads allocated. Then you allocate every other process to use other threads in the cpu, lower their priority to ridiculously low levels and hope you didn't freeze the PC
    there's gotta be a better way. since i can't expect a LTT sc2 optimization video what about one of those cpu intensive games that linux plays? is there a video idea in finding a software that allows you to change priority/affinity settings, like process explorer, and seeing if it can give you better frames?

    • @henlofren7321
      @henlofren7321 Před 11 měsíci

      None of that will help you, you need a 5800x3d.

  • @anthonymorris8891
    @anthonymorris8891 Před 11 měsíci +1

    What has Best Buy been doing differently that would make LMG agree to be associated with them?

  • @RaxXxvell
    @RaxXxvell Před 11 měsíci

    Very informative for someone who already knows most of this, but it takes half the video to describe the scheduler on a single core, then what gets avoided and that libraries help together with the hardware itself, but the actual part of how the multitasking is done and how threads are executed on multiple is packed into 10 seconds with a small list. I miss a little: and that all culminates into etc etc. and a little more explanation there.
    Still enjoyed the video though.

  • @flameshana9
    @flameshana9 Před 11 měsíci

    *Windows Defender:* Imagine following rules. I'll scan your system whenever I darn well please. And I'll make _sure_ to do it while you're working.

  • @ausername9190
    @ausername9190 Před 11 měsíci

    this is so much more interesting when it is not being taught for my computer science A level, and instead as interest to the subject

  • @mufeedtalukder4556
    @mufeedtalukder4556 Před 11 měsíci +3

    The Windows logo really be like: 👁️ 👄 👁️

  • @Omnifarious0
    @Omnifarious0 Před 11 měsíci

    There is generally useful information here, but a lot of it is also very Windows specific.
    I would actually appreciate a breakdown that also covered how Linux scheduling worked. I haven't looked in detail at this problem for a very long time, and definitely not since multiple cores became common. And for asymmetric cores, this must get even more complicated still.

  • @thebenji8653
    @thebenji8653 Před 11 měsíci

    This video makes me want a more in depth video to fuller explain this to me. I think I get it, but not entirely.

  • @1year1meme84
    @1year1meme84 Před 11 měsíci +1

    Cool video, but Linus mentions Windows all the time during the video. If I'm not mistaken, these mechanics happen for every operating system

  • @ak_hoops
    @ak_hoops Před 11 měsíci

    I pray Techquickie never ceases to exist

  • @RobertForslund
    @RobertForslund Před 11 měsíci +2

    I have no problem believing that the one person who could actually multitask, it would be Yvonne! 😁👍

  • @tobiahhowell
    @tobiahhowell Před 11 měsíci

    Man, all those vocab words from my Real Time Operating System class are coming back to me... What is a Process, and what is a Thread? The question that was asked on every exam.😂

  • @imacgra1
    @imacgra1 Před 11 měsíci +1

    To save on your electricity bill, and to save the planet 3:58

  • @im36degrees
    @im36degrees Před 11 měsíci

    clear as mud

  • @AlanTheBeast100
    @AlanTheBeast100 Před 11 měsíci

    How did that definition of a context switch get in there?

  • @moayadkassem
    @moayadkassem Před 10 měsíci

    cool! Which CPU company is more preferred (works better) by Windows's CPU Scheduling?