The Fetch-Execute Cycle: What's Your Computer Actually Doing?

Loading...
  • Published on: 29 July 2019
  • The fetch-execute cycle is the basis of everything your computer or phone does. This is literally The Basics. • Sponsored by Dashlane —try 30 days for free at: https://www.dashlane.com/tomscott

    Thanks to Dashlane for sponsoring the video! If you're techie enough to watch this video, you should be using a password manager. Get a 30-day free trial at https://dashlane.com/tomscott

    MORE BASICS: https://www.youtube.com/playlist?list=PL96C35uN7xGLLeET0dOWaKHkAlPsrkcha

    MINOR CORRECTIONS:
    In the graphics, "programme" should be "program".
    I say "Mac instead of PC"; that should be "a phone instead of a PC".
    And most importantly, I say "every sixth cycle": that should be "every ninth".
    Fortunately, none of these materially affect the content of the video!

    Written by Sean M Elliott and Tom Scott
    Directed by Tomek
    Graphics by Mooviemakers https://www.mooviemakers.co.uk/
    Audio mix by Haerther Productions https://haerther.net/



    I'm at https://tomscott.com
    on Twitter at https://twitter.com/tomscott
    on Facebook at https://facebook.com/tomscott
    and on Instagram as tomscottgo
  • Runtime : 9:4
  • tom scott tomscott the basics computer science fetch-execute fetch-execute cycle fetch-decode-execute cycle fetch-decode-execute cpu ram

COMMENTS: 40

  • Tom Scott
    Tom Scott   2 months ago

    And away we go with another season of three computer-science videos! A whole team made this happen: pull down the description for all the details! And thanks to Dashlane for sponsoring: you can find more about them at https://www.dashlane.com/tomscott

  • Anders Struck
    Anders Struck   1 weeks ago

    Good thing you didn't include pipelining, multi-layer caches or different architectures (register to register vs register to mem, etc)

  • Overbite Games
    Overbite Games   2 weeks ago

    watching this with a wrist injury has my hands feeling a certain way.Ouch.

  • Gull Lars
    Gull Lars   2 weeks ago

    I did code a 16-bit RISC assembly program once for a project, which was an interpreter for ASCII encoded commands and piping of data in an FPGA soft core to control the hardware blocks' functionality. There are some really clever things you can do at the machine code level to make your code small and fast, but to do so correctly is very hard and basically requires you to be able to step through the code flow in your head (or with flowcharts for assistance). If you think refactoring c++, java or C# is hard, try refactoring hundreds or thousands of lines of assembly. Some experience with code golfing can come in really handy then. (our case was on the order of 450-500 lines of an initial assembly implementation getting refactored and reduced to 150 lines because of a need to keep more data state in the limited registers, and a severe penalty for too much memory access to shuffle data between RAM and registers.

  • Rei
    Rei   2 weeks ago

    lil glitchy there

  • EramsorGR
    EramsorGR   2 weeks ago

    I should make a song of Tom saying "fetch, decode, execute"

  • losthor1zon
    losthor1zon   2 weeks ago

    Nice demonstration. I'm only disappointed that you didn't give an example of assembly language so that people can see what it looks like. (I vaguely remember 8080 / Z80 assembler, but any would do.)

  • Daniel Wilson
    Daniel Wilson   3 weeks ago

    Ah, good ol' ECE 4613 -- Computer Architecture. That example's a little on the slow side, though -- typically you'll see some pipelining, with instruction 2 loading while instruction 1 decodes, or rather instruction 2 loading and decoding while instruction 1 goes about the rather slower process of executing (provide the execute phase hasn't been split up and not counting speeding things along some more by making memory accesses another phase in the pipe). That way once the pipe fills up, you're burning through a phase of as many instructions as you have pipeline phases all at once (which gives the components no respite, often making them switch every clock cycle, dramatically increasing heat build-up), making for big ol' gains in throughput when not frustrated by conditional jumps making a missed branch prediction mean dumping large portions of the pipe, leaving a so-called "bubble".I sure can see why you left it out, though!

  • Dojel Notmyrealname
    Dojel Notmyrealname   3 weeks ago

    Wouldn't the fetch/decode/execute be happening simultaneously? Most CPU's are pipelined like that in my understanding.

  • KidUKnott
    KidUKnott   3 weeks ago

    I love your The Basics series, Tom. Do keep them coming. I bet it's a lot of work to come up with topics and make them, but they are awesome. I wish I'd watched these ten years ago. Subscribed.

  • Deeptadeep Roy
    Deeptadeep Roy   3 weeks ago

    very well explained... definitely better than my microprocessor book... got myexam tomorrow... this definitely helped

  • Cyrus Hale
    Cyrus Hale   1 months ago

    I'm tech enough to use something betting than dashlane.

  • Dr Logiq
    Dr Logiq   1 months ago

    What's my computer actually doing? Well, Tom... most of the time it's just doing whatever it feels like, which is almost never what I need it to be doing! Blummin' Windows 10 mumble mumble "Don't turn off your computer" mumble ...This is a great explanation, nice and concise :)

  • Kiki Tay
    Kiki Tay   1 months ago

    Where can I find more about what's going on in his video's background?

  • joshmbrown42
    joshmbrown42   1 months ago

    As someone who's studied CS in the US, "programme counter" really threw me off for a few seconds.

  • talzO9
    talzO9   1 months ago

    is that a green screen

  • VidarW
    VidarW   1 months ago

    Great video. Great snapping.

  • felix34ever1
    felix34ever1   1 months ago

    This helps so much with computer science, now I understand what's actually happening at the bits of the cpu

  • Arfnudaniack Blue
    Arfnudaniack Blue   1 months ago

    And a system is only as good as the person in charge of designing it.

  • Isaac Clodfelter
    Isaac Clodfelter   1 months ago

    Higher level programming languages are just the endless cycle of computer programmers programming programs to program their programs just a little better. I love it.

  • Maghil vannan
    Maghil vannan   1 months ago

    @Tom Scott can you do a video about how pipelining is done in a basic level

  • Forgan Mreeman
    Forgan Mreeman   1 months ago

    if i’ve said it once i’ve said it 100x, programmers are actual aliens. or i’m an idiot. i had trouble keeping up with this very simple example. i failed two programming courses in a row while studying for my computer science degree. it made me drop out. i’m just not a programmer. kudos to those who are. it’s an incredible feat

  • Luminescent Lion
    Luminescent Lion   1 months ago

    Isnt the clock on the MoBo though, CPU just takes that and runs it through a multiplier to get its speed(in hertz), which it runs the instructions at.

  • burbon ­
    burbon ­   1 months ago

    these snaps are making my fingers hurt...

  • Gerrit Zimmermann
    Gerrit Zimmermann   1 months ago

    If all humans were snapping their fingers simultaneously, with both hands, it would still not be sufficient to drive that virtual CPU to the same speed a bog-standard multicore processor works at nowadays ...

  • Mitch Connor
    Mitch Connor   1 months ago

    the finger snapping made me uncomfortable.

  • Qwerty-Space
    Qwerty-Space   1 months ago

    The original Roller Coaster Tycoon is a good example of a game written in Assembly!!

  • Acheron Hades
    Acheron Hades   1 months ago

    love that ublock origin in the dashlane ad!

  • Dave Thackeray
    Dave Thackeray   1 months ago

    To demonstrate my abject stupidity I still don't understand how a basic computer works.

  • Gustav Krause
    Gustav Krause   1 months ago

    did your finger actually hurt after recording this footage?Edit: Also this sponsoring ist nice cause it's actually related to your content and you give a detailed explanation on password managers too, so props for that :)