The Fetch-Execute Cycle: What's Your Computer Actually Doing?
The Fetch-Execute Cycle: What's Your Computer Actually Doing?
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
is that a green screen
Mine is downloading porn
I should make a song of Tom saying "fetch, decode, execute"
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
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 …
@Tom Scott can you do a video about how pipelining is done in a basic level
Where can I find more about what’s going on in his video’s background?
If you want to learn more, check out Ben Eater’s series on constructing an 8 bit CPU.
you love red
God Bless Scott’s Tot’s
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.)
4:45 snapping skills are a little scary at this point
Most indirect flex
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.
watching this with a wrist injury has my hands feeling a certain way.
Ouch.
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!
This helps so much with computer science, now I understand what’s actually happening at the bits of the cpu
The original Roller Coaster Tycoon is a good example of a game written in Assembly!!
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 🙂
Great video! Alan Turing deserves mention here.
Sorry, I still don’t get it. I guess I need it dumbed down even more
Tom, you are a bloody wizard
People who unironically code in assembly for fun are masochists
I’ve watched this video three times in a row and my brain still refuses to understand most of it, am I small brain ?
Interesting video! I know this is an oversimplified example, but isn’t the fetch -> decode -> execute process of a CPU done in one clock cycle? Fetch -> decode -> execute is carried over a series of logic gates that only depend on one clock cycle to process an instruction.
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.
lil glitchy there
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.
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
Are you trying to hypnotize me tom?
Register? I thought that was a cache
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.
As someone who’s studied CS in the US, "programme counter" really threw me off for a few seconds.
To demonstrate my abject stupidity I still don’t understand how a basic computer works.
RIP Tom Scott
I’m tech enough to use something betting than dashlane.
If you get into it further it gets even cooler. Modern cpus take those instructions and execute them out of order if one needs to wait, they do those jump instructions before they know they actually need to to do work in advance, they do all three of those steps (fetch, decode, execute) at the same time for multiple instructions, and many don’t even have a specific set of bits for each register: they just rename and move them around as time passes to allow that parallelism from earlier to work properly.
these snaps are making my fingers hurt…
very well explained… definitely better than my microprocessor book… got myexam tomorrow… this definitely helped
Great video. Great snapping.
All of that so people can watch porn.
the finger snapping made me uncomfortable.
This is crazy I can’t believe my laptops so hardworking
love that ublock origin in the dashlane ad!
Good thing you didn’t include pipelining, multi-layer caches or different architectures (register to register vs register to mem, etc)
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 🙂
Wouldn’t the fetch/decode/execute be happening simultaneously? Most CPU’s are pipelined like that in my understanding.
Each one of his snaps were so impressive the shockwave came through my phone and ended the life of 10 of my brain cells
And a system is only as good as the person in charge of designing it.
6:19 JAVA ENTERS CHAT