[CS61C FA20] Lecture 30.3 - Virtual Memory II: TLBs in Datapath — Transcript
Full transcript
- 0:00[Music]
- 0:10hello
- 0:11and welcome back to our operating system
- 0:14and virtual memory module so far
- 0:17we have figured out how do virtual
- 0:20memory systems work
- 0:22and we have seen the role of translation
- 0:25leukocyte buffers or tlbs
- 0:27in accelerating this translation from
- 0:29virtual addresses to physical addresses
- 0:31all what is left now is to just
- 0:35implement that in our pipeline
- 0:39so let's do that so it actually could be
- 0:42left as an exercise to the listener but
- 0:44we are nevertheless go ahead and
- 0:46walk through the implementation
- 0:49so here is our five-stage pipeline that
- 0:51we have seen before
- 0:54we obviously see one modification that
- 0:57is in here
- 0:58it is insertion of two tlbs
- 1:02in front of the instruction cache and
- 1:04the data cache
- 1:06because we remember that
- 1:09tlbs need to precede the cache our part
- 1:12encounter
- 1:13is going to issue virtual addresses tlb
- 1:16is going to translate these virtual
- 1:18addresses
- 1:19into the physical addresses before they
- 1:21go into the cache
- 1:23similarly our data memory references are
- 1:27going to be virtual
- 1:29before they reach the tlb tlb is going
- 1:32to translate them
- 1:33to the physical ones now there are
- 1:35several
- 1:37events that these tlbs also
- 1:40need to alert us to
- 1:43whether we have a tlb miss was there a
- 1:46page fault
- 1:47and is there a protection violation
- 1:51so how do we handle those
- 1:55first let's take a look at tlb misses
- 1:57handling a tlb
- 1:58miss needs a harder or softer mechanism
- 2:02to essentially walk the page tables and
- 2:04update the tlp
- 2:06in most current machines it is done
- 2:09in hardware and it can be done fairly
- 2:12quickly
- 2:13it's essentially what we are looking at
- 2:14is an implementation of a
- 2:18straightforward perhaps not so simple
- 2:20the
- 2:21state machine that is going to do that
- 2:24on the other hand handling a page fault
- 2:29needs a precise trap and we have seen
- 2:32how we implement those
- 2:34so if there is a if there is a page
- 2:38fault
- 2:38we need to stop that um
- 2:42and cancel that loader store instruction
- 2:44because it is going to take forever
- 2:47so we will perform a precise trap
- 2:51cancel it and call the operating system
- 2:54operating system will do something else
- 2:56most likely
- 2:57a context switch
- 3:01so once when the
- 3:06the page is available in dram will
- 3:09resume
- 3:11execution from exact that same
- 3:14instruction
- 3:15finally if there is a protection
- 3:17violation
- 3:18generally os needs to know about that
- 3:21and
- 3:22would typically abort the
- 3:25current process that made the protection
- 3:28violation
- 3:30okay let's take a look
- 3:33a bit at the practical implementation
- 3:36here
- 3:38so we can take our standard five-stage
- 3:40pipeline that we have already worked
- 3:42with
- 3:42and what we need to do is add our tlps
- 3:47now one thing to notice here is
- 3:51we have added a memory controller memory
- 3:53controller
- 3:55works with the two caches the
- 3:57instruction cache
- 3:58and the data cache it is essentially
- 4:04a digital a chunk of digital logic
- 4:07that translates things from the
- 4:10processor
- 4:11speak to the dram speak so
- 4:14it is a pretty large digital system that
- 4:18essentially
- 4:18knows how to work with the dram knows
- 4:21how to
- 4:22refresh it knows
- 4:25how to issue reads and writes and how to
- 4:29do
- 4:30bursts and so on this is not something
- 4:33that we are going to cover
- 4:34in 61c or actually
- 4:38anywhere in our curriculum this is
- 4:40something that
- 4:42commonly is a piece of ip intellectual
- 4:45property
- 4:46that you buy on the market to integrate
- 4:48in your product
- 4:50unless you're a really big company that
- 4:52has their own
- 4:54memory controllers okay but the things
- 4:58that do need to exist in our
- 4:59processor uh is the support
- 5:02for handling
- 5:06page misses so if there is a
- 5:10miss in a tlb
- 5:13what we need to do is we need to
- 5:17walk the page tables and that is
- 5:19typically done as a hardware state
- 5:21machine
- 5:22it starts from the page table base
- 5:24register
- 5:25that is set for every process that is
- 5:28being executed
- 5:29and page table walker goes and updates
- 5:33the tlbs
- 5:36as we have seen we essentially see in
- 5:38the process
- 5:39of that when that is done correctly we
- 5:41see a translation from virtual addresses
- 5:44to the physical addresses at appropriate
- 5:46locations
- 5:51a few other things we basically need to
- 5:54signal if we
- 5:55encounter a page fault or protection
- 5:58violation
- 5:59either in the instructions or in the
- 6:03data tlp okay so
- 6:07that's basically it
- 6:11to put it all together here is how does
- 6:14android
- 6:15translation look like in a practical
- 6:16system and we are
- 6:18outlining here things that are done in
- 6:20hardware
- 6:22or in software or can be done in either
- 6:25of those most of the the time nowadays
- 6:28these
- 6:29things are done in hardware that can be
- 6:31done either in hardware and software
- 6:34that's why we made them more like these
- 6:37lime greenish than orange-ish so when we
- 6:40start with a
- 6:42virtual address we're going to go
- 6:45through a tlb
- 6:45lockup most of the time 99.9
- 6:50something time you're going to have a
- 6:52hit
- 6:54if you have a hit we need to check those
- 6:57bits that are in in our tlb
- 7:00and whether we are permitted to
- 7:04do the the operation that we wanted to
- 7:06do read write or execute
- 7:07if we are we issue a physical address
- 7:10and that goes to the cache and we
- 7:12proceed
- 7:14further if we are denied we have a
- 7:17protection fault
- 7:18that is handled in software by the
- 7:21operating system
- 7:22and generally the user sees
- 7:25a segfault error
- 7:31now going back to a tlb lockup if we
- 7:33have a
- 7:34tlb miss we need to perform a page table
- 7:38walk
- 7:38that can be done in software hardware
- 7:40but generally now is done in hardware
- 7:43and if the page is in the memory
- 7:46we'll update the tlb and carry on
- 7:49that happens quickly a few clock cycles
- 7:51and we're good
- 7:52if the page is not in the memory it's in
- 7:54the disk we
- 7:56are going to issue a page fault so
- 7:59and let os load the page and do
- 8:02something else in the meantime
- 8:03while that page is coming from the disk
- 8:07and that's it so few other summary
- 8:10points here
- 8:11modern virtual memory systems are there
- 8:14to provide an
- 8:15illusion of a large private uniform
- 8:18store and we have seen how we do that
- 8:21how many of these mechanisms
- 8:23go together to make sure that the data
- 8:26always looks like it's right there
- 8:28that is within one cycle even though
- 8:31it could be on on pluto
- 8:38so we are you know there are several
- 8:40other things that they're implementing
- 8:42implemented along the way protection and
- 8:44privacy that several
- 8:46um users and processes can
- 8:50coexist in a processor and each one of
- 8:52them is going to have their private
- 8:54address space we do that through the
- 8:57demand paging that provides the ability
- 8:59to run programs
- 9:01larger than the primary memory and that
- 9:04is also very useful because it
- 9:06hides differences in machine
- 9:08configurations people can have different
- 9:10hardware
- 9:11and still run the same software
- 9:17the price for doing that is in the
- 9:20memory translation and what we do we use
- 9:22tlbs to accelerate that
- 9:25and they work seamlessly with the caches
- 9:28to make our machines
- 9:32look like they're infinitely fast and
- 9:34work with infinitely large memory
- 9:38finally now we actually know
- 9:41how to define what is happening in a
- 9:43context switch
- 9:45so how does a processor run many
- 9:47programs at once
- 9:50it uses context switches they're
- 9:52typically set
- 9:53by the timer or by
- 9:56could be done by some external event
- 9:58like a page fault
- 10:01that on the context switch the operating
- 10:04system is going to change the internal
- 10:06state of a processor
- 10:09to switch between the processes it has
- 10:11to save all the registers including the
- 10:13pc
- 10:15and change that
- 10:18value in the supervisor table base
- 10:20register
- 10:22or that spt-br such that we can
- 10:27point to a different set of page tables
- 10:30what happens to the tlb well it's
- 10:33invalid it corresponds to the
- 10:34old process so it needs to be updated
- 10:38and that's it after this we're going to
- 10:40evaluate the
- 10:42performance of our virtual memory system
- 10:45and wrap up with the module move after
- 10:48that
- 10:48to io see you after our quick break
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 30.3 - Virtual Memory II: TLBs in Datapath by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,363 words across 258 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.