How CPUs Use Multiple Cores

Sdílet
Vložit
  • čas přidán 29. 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 rokem +1279

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

  • @tannerted
    @tannerted Před rokem +515

    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 rokem +41

      Was looking for this reply or going to do it myself

    • @andrebrait
      @andrebrait Před rokem +20

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

    • @rohansampat1995
      @rohansampat1995 Před rokem +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 rokem +9

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

    • @ChristopherHailey
      @ChristopherHailey Před rokem +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 rokem +418

    "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 rokem +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 rokem

      He eats CPU for breakfast
      & Then poops multitasking

    • @lordfalke8117
      @lordfalke8117 Před rokem

      Hello there

    • @extremepsykosis
      @extremepsykosis Před rokem

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

  • @jimflagg4009
    @jimflagg4009 Před rokem +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 rokem +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 rokem +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 rokem +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 rokem +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 rokem +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

  • @dampfwatze
    @dampfwatze Před rokem +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 rokem

      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 rokem +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 rokem +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 rokem +1

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

  • @negativepremium4100
    @negativepremium4100 Před rokem +66

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

    • @EveningOfficer
      @EveningOfficer Před rokem +2

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

    • @YounesLayachi
      @YounesLayachi Před rokem

      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 rokem +48

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

  • @notenoughmonkeys
    @notenoughmonkeys Před rokem +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 rokem +2

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

  • @jwlee21
    @jwlee21 Před rokem +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 rokem +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 rokem +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 rokem

      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 rokem +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.

  • @insu_na
    @insu_na Před rokem +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 rokem +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 rokem +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 rokem +1

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

    • @neiljp-dev
      @neiljp-dev Před rokem +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 rokem

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

  • @SingleRacerSVR
    @SingleRacerSVR Před rokem +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 rokem +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 rokem +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 rokem +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 rokem

      @@psoltandaddy chill

    • @SupaKoopaTroopa64
      @SupaKoopaTroopa64 Před rokem +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.

  • @Xpurple
    @Xpurple Před rokem +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 rokem +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 rokem +2

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

    • @GSBarlev
      @GSBarlev Před rokem +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 rokem +1

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

  • @laughingseal007
    @laughingseal007 Před rokem +13

    I love me some Fast As Techquicke

  • @savagepro9060
    @savagepro9060 Před rokem +14

    Linus: How CPUs Use Multiple Cores?
    Single Cores:

  • @benjaminclehmann
    @benjaminclehmann Před rokem +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 rokem +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 rokem +1

      Sex*, not gender.

    • @flameshana9
      @flameshana9 Před rokem +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 rokem +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 rokem

      @@ninjadev64 thanks

    • @Forty2de
      @Forty2de Před rokem +1

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

  • @Eli-zb2yj
    @Eli-zb2yj Před rokem +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 rokem +4

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

  • @clayton_games
    @clayton_games Před rokem +1

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

  • @MarioGoatse
    @MarioGoatse Před rokem +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 rokem +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 rokem

      Welcome to Tech "quickie" ?

    • @ChristopherHailey
      @ChristopherHailey Před rokem +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 rokem

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

    • @ChristopherHailey
      @ChristopherHailey Před rokem +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 rokem +1

      @@ChristopherHailey Linus Sorta Accurate Tips

  • @sviffls1833
    @sviffls1833 Před rokem +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 rokem +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 rokem

      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.

  • @ethanberg3343
    @ethanberg3343 Před rokem +2

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

  • @LarkyLuna
    @LarkyLuna Před rokem +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

  • @alexferguson5346
    @alexferguson5346 Před rokem +2

    Those animations are going to haunt my nightmares

  • @bacon.cheesecake
    @bacon.cheesecake Před rokem +1

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

  • @satrioadi7044
    @satrioadi7044 Před rokem +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

  • @StuckOnAFireHydrant
    @StuckOnAFireHydrant Před rokem +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.

  • @r.g7261
    @r.g7261 Před rokem +1

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

  • @kiosfriend
    @kiosfriend Před rokem +2

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

  • @OldGamerNoob
    @OldGamerNoob Před rokem

    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 rokem

    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 rokem +2

    00:45 this is the GloryThread

  • @SupaaMann
    @SupaaMann Před rokem +1

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

  • @laszloperneky8417
    @laszloperneky8417 Před rokem +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

  • @commandurrazor
    @commandurrazor Před rokem

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

  • @EnbyCatboyGF
    @EnbyCatboyGF Před rokem +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.

  • @ThunderBlastvideo
    @ThunderBlastvideo Před rokem

    ive ALWAYS wanted to know this! thanks!

  • @jason6618
    @jason6618 Před rokem +2

    Best buy sponsor. Did not expect that.

  • @johndoh5182
    @johndoh5182 Před rokem +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.

  • @bogata903
    @bogata903 Před rokem +1

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

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

  • @oksowhat
    @oksowhat Před rokem +1

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

    • @ChristopherHailey
      @ChristopherHailey Před rokem

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

  • @MetalMan1245
    @MetalMan1245 Před rokem

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

  • @addledhead
    @addledhead Před rokem

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

  • @DatBoiTip
    @DatBoiTip Před rokem +1

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

  • @jtmcdole
    @jtmcdole Před rokem +1

    That chip animation is nightmare fuel.

  • @Random_dud31
    @Random_dud31 Před rokem +1

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

  • @nclark5720
    @nclark5720 Před rokem

    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

  • @wassimajili5983
    @wassimajili5983 Před rokem +1

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

  • @kipchickensout
    @kipchickensout Před rokem +1

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

  • @SDRIFTERAbdlmounaim
    @SDRIFTERAbdlmounaim Před rokem +2

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

  • @ari-mcbrown
    @ari-mcbrown Před rokem +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.

  • @owenarnold8117
    @owenarnold8117 Před rokem +1

    Very good vid!

  • @stalememe3305
    @stalememe3305 Před rokem +2

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

  • @adsy6819
    @adsy6819 Před rokem +1

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

  • @squirtle88
    @squirtle88 Před rokem

    more videos like this please

  • @sam19953
    @sam19953 Před rokem +1

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

  • @Goodsdogs
    @Goodsdogs Před rokem

    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 rokem

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

  • @usopenplayer
    @usopenplayer Před rokem

    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.

  • @jamtea388
    @jamtea388 Před rokem

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

  • @eshakrafi5797
    @eshakrafi5797 Před rokem

    Your explanation was very good ❤

  • @milind8751
    @milind8751 Před rokem

    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?

  • @doctor_gee
    @doctor_gee Před rokem +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 rokem +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 rokem

      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

  • @hanswurst9120
    @hanswurst9120 Před rokem +1

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

  • @monoklmen
    @monoklmen Před rokem

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

  • @hovant6666
    @hovant6666 Před rokem +1

    those were some creepy animations m8

  • @1year1meme84
    @1year1meme84 Před rokem +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

  • @arunnaik622
    @arunnaik622 Před rokem

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

  • @flameshana9
    @flameshana9 Před rokem

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

  • @PanchoMngkn
    @PanchoMngkn Před rokem

    Thank you for your videos Linus ❤

  • @CMDR_John_Crichton
    @CMDR_John_Crichton Před rokem

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

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

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

  • @RaxXxvell
    @RaxXxvell Před rokem

    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.

  • @bgezal
    @bgezal Před rokem

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

  • @AutumnRain
    @AutumnRain Před rokem +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

  • @Shini1171
    @Shini1171 Před rokem

    Right before my CPU finals. cheers!

  • @Jon717
    @Jon717 Před rokem

    3:59 The Spiffing Brit build

  • @cadenchurchill4296
    @cadenchurchill4296 Před rokem +1

    Me: I’m a smart adult educating myself about tech with Linus!
    Also me: pee cores, hee hee 😂😅

  • @ayaanbari6711
    @ayaanbari6711 Před rokem

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

  • @srobak
    @srobak Před rokem

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

  • @Omnifarious0
    @Omnifarious0 Před rokem

    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.

  • @RobertForslund
    @RobertForslund Před rokem +2

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

  • @im36degrees
    @im36degrees Před rokem

    clear as mud

  • @mufeedtalukder4556
    @mufeedtalukder4556 Před rokem +3

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

  • @anthonymorris8891
    @anthonymorris8891 Před rokem +1

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

  • @ak_hoops
    @ak_hoops Před rokem

    I pray Techquickie never ceases to exist

  • @tobiahhowell
    @tobiahhowell Před rokem

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

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

    The E cores actually aren't more power efficient clock for clock as the P cores. The E is more about die area efficiency than power efficiency.
    Intel is fitting 4 E cores in the same physical space as one E core. Since each E core is ~40% of a P core, you come out ahead if they're utilized well.

    • @Frozoken
      @Frozoken Před 8 měsíci

      Ur right in the fact that they main goal is multithreading performance like a traditionally named mid core on mobile but they are also more efficient power wise. I find that roughly 4 ecores and a single non hyper threaded p core use the same power. Absolutely more power efficient obviously. Not to mention that ecores perform much better performance and power wise when using 1/4 of the cluster like how it would actually typically be used. One reason for this and theres many more complex ones too is that one ecore can use all the cluster's l2 cache for itself while all 4 have to share that same bandwidth plummeting ipc. Chips and cheese showed this. Oh yeah and it seems windows knows too, when playing games in my 13600k my very first and very last ecore have massively more utilisation consistently

  • @pgplaysvidya
    @pgplaysvidya Před rokem +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 rokem

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

  • @HuntersOA
    @HuntersOA Před rokem

    This with thread priority is the bane of our existence at work :D We use windows based machines for test systems as our IT does not allow linux or other. The microsoft scheduler has a really weird approach to things - and on of them is that they always have "user experience" at the top. So mouse movement, etc. For us, this often causes that Windows does not get the data out of the network cards buffer "fast enough". In time sensitive applications - such as communication with a measurement device, this sometimes causes the communication to brake down :D And we have not yet found a suitable workaround for this other then giving the systems more "timeouts" to account for windows scheduling...

    • @HuntersOA
      @HuntersOA Před rokem

      @@breaddough-vk8gf not our softwarw is the problematic. The network card recieves the data packets, but windows scheduler does not read them out. Unfortunately it has little to do with our software :D

    • @HuntersOA
      @HuntersOA Před rokem

      @@breaddough-vk8gf The issue is with TCP its self - the data packets arrive and are confirmed, however, they are not read out from the pcie gigabit card in time :D Thus our software can not prepare the proper responses to the sending device. Funny gummy. Do not use regular windows for measurement systems :)

    • @HuntersOA
      @HuntersOA Před rokem

      @@breaddough-vk8gf the thing is, they are not dropped :D The control is event driven and packets get into a fifo. Windows does not read out the packets from the card for up to 300ms - while we expect loop cycle times under 20ms. This means by the time the packet gets to our code it is obsolete for the HW connected on TCP and the communication brakes down. No packet was lost, but the delay causes an async behaviour which results in errors as time stemps are "too old" :D The thing is, this is because user experience is above all else. If you game or something, this does not happen. Of you have a measurement system - and a test is running. Than the operator opens a PDF -> you get this :D Also it is attrocious if xou connect via RDP, than it can be a skip of 2-3 seconds :D RDP really messes windows up

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

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

  • @ausername9190
    @ausername9190 Před rokem

    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

  • @deldarel
    @deldarel Před rokem +1

    "but is that how your cpu works?"
    Me, a python developer: "yes"

    • @BrianG61UK
      @BrianG61UK Před rokem

      I think multithreaded Python is a thing now. But even ignoring that, he goes straight on to say a core can switch from running one thread to running another one.

  • @_shadow_1
    @_shadow_1 Před rokem

    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.

  • @tamertamertamer4874
    @tamertamertamer4874 Před rokem +2

    Hello programmers ! Make sure to use locks when you make threads that share the same variables ! You don’t want any race conditions :)

  • @LTT.Official
    @LTT.Official Před rokem

    Thanks to our sponsors

  • @thebenji8653
    @thebenji8653 Před rokem

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