<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F_Lecture_8</id>
	<title>Operating Systems 2019F Lecture 8 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2019F_Lecture_8"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_8&amp;action=history"/>
	<updated>2026-05-18T21:41:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_8&amp;diff=22473&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on September 27, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec08-20190927.m4v is now available]....&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_8&amp;diff=22473&amp;oldid=prev"/>
		<updated>2019-09-27T21:33:09Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on September 27, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec08-20190927.m4v is now available]....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on September 27, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec08-20190927.m4v is now available].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 8&lt;br /&gt;
---------&lt;br /&gt;
&lt;br /&gt;
In tutorial 3, you saw mmap.  To explain this, we must discuss...&lt;br /&gt;
&lt;br /&gt;
virtual memory!&lt;br /&gt;
&lt;br /&gt;
On every memory access, the CPU must&lt;br /&gt;
  get virtual address&lt;br /&gt;
  map virtual address to a physical address&lt;br /&gt;
  read memory (in cache or main memory) from physical address&lt;br /&gt;
&lt;br /&gt;
this mapping is managed by the MMU (memory management unit)&lt;br /&gt;
&lt;br /&gt;
No MMU, no virtual addresses&lt;br /&gt;
&lt;br /&gt;
To really make things fast, we have the fastest cache in the CPU&lt;br /&gt;
 - the TLB (translation lookaside buffer)&lt;br /&gt;
 - caches virtual-&amp;gt;physical memory mappings&lt;br /&gt;
&lt;br /&gt;
because mappings have to be stored in RAM somewhere..the TLB caches them&lt;br /&gt;
&lt;br /&gt;
What is a cache?&lt;br /&gt;
&lt;br /&gt;
memory hierarchy&lt;br /&gt;
-----------------&lt;br /&gt;
&lt;br /&gt;
wide range of storage:&lt;br /&gt;
  * fast and small to large and slow&lt;br /&gt;
&lt;br /&gt;
VOLATILE&lt;br /&gt;
&lt;br /&gt;
CPU registers&lt;br /&gt;
TLB&lt;br /&gt;
level 1 cache&lt;br /&gt;
level 2 cache&lt;br /&gt;
level 3 cache&lt;br /&gt;
main memory (RAM)&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
NON VOLATILE&lt;br /&gt;
&lt;br /&gt;
solid state disk&lt;br /&gt;
spinning hard drive&lt;br /&gt;
tape drive&lt;br /&gt;
&lt;br /&gt;
memory hierarchy works as long as we can have high temporal and spatial locality&lt;br /&gt;
&lt;br /&gt;
spatial:&lt;br /&gt;
 - accessing one byte means we&amp;#039;ll access nearby bytes&lt;br /&gt;
&lt;br /&gt;
temporal:&lt;br /&gt;
 - accessing one byte means we&amp;#039;ll access the same byte nearby in time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hardware manages level 1-3 caches, TLB (generally)&lt;br /&gt;
compiler manages CPU registers&lt;br /&gt;
OS kernel manages main memory and disk&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What would be the optimal algorithm for managing main memory?&lt;br /&gt;
 - predict future&lt;br /&gt;
 - throw out data that won&amp;#039;t be used, load data that will be&lt;br /&gt;
&lt;br /&gt;
In practice, we mostly use LRU (least recently used)&lt;br /&gt;
 - if you haven&amp;#039;t accessed it recently you probably won&amp;#039;t in the future&lt;br /&gt;
&lt;br /&gt;
Memory is managed in fixed-sized chunks always&lt;br /&gt;
 - reduces overhead&lt;br /&gt;
&lt;br /&gt;
Typically 4K or 8K, but can be multiple megabytes&lt;br /&gt;
&lt;br /&gt;
If it is on disk, it is a block&lt;br /&gt;
If it is in RAM, it is a page&lt;br /&gt;
&lt;br /&gt;
Page table&lt;br /&gt;
 - data structure that maps virtual to physical memory,&lt;br /&gt;
   at page-level granularity&lt;br /&gt;
&lt;br /&gt;
each process has its own page table&lt;br /&gt;
&lt;br /&gt;
CPU (the MMU part) walks the page table to map virtual to physical addresses&lt;br /&gt;
  - and caches results in the TLB&lt;br /&gt;
&lt;br /&gt;
pages (virtual pages) are stored in frames (physical memory)&lt;br /&gt;
&lt;br /&gt;
when the CPU finds nothing corresponding to a virtual address, the OS gets called&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>