<?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_2020W_Lecture_21</id>
	<title>Operating Systems 2020W Lecture 21 - 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_2020W_Lecture_21"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Lecture_21&amp;action=history"/>
	<updated>2026-06-02T21:08:13Z</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_2020W_Lecture_21&amp;diff=22622&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on March 27, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec21-20200327.m4v is now available].  ==...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Lecture_21&amp;diff=22622&amp;oldid=prev"/>
		<updated>2020-03-27T20:33:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on March 27, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec21-20200327.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 March 27, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec21-20200327.m4v is now available].&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
&lt;br /&gt;
* [https://www.acm.org/hennessy-patterson-turing-lecture Turing Award talk by John Hennessy and David Patterson]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Memory_hierarchy Wikipedia page on Memory Hierarchy]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/CPU_cache Wikipedia page on CPU caches]&lt;br /&gt;
* [https://en.wikichip.org/wiki/amd/microarchitectures/zen Wikichip&amp;#039;s page on AMD&amp;#039;s Zen microarchitecture]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 21&lt;br /&gt;
----------&lt;br /&gt;
 - tutorial 8&lt;br /&gt;
 - tutorial 9&lt;br /&gt;
&lt;br /&gt;
Standard address space ordering&lt;br /&gt;
&lt;br /&gt;
command line args, env vars&lt;br /&gt;
stack (grows down)&lt;br /&gt;
&lt;br /&gt;
heap (grows up)&lt;br /&gt;
globals&lt;br /&gt;
code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Virtual memory systems rely on page replacement algorithms&lt;br /&gt;
 - decide when to kick out a page in order to make room for another in RAM&lt;br /&gt;
 - we use bits in the page table entries to decide what to do&lt;br /&gt;
   - valid bit: is this a valid PTE?&lt;br /&gt;
   - accessed bit: recently accessed (approximation of a timestamp)&lt;br /&gt;
   - dirty bit: has it been changed (i.e., do we have to save it before&lt;br /&gt;
     evicting it?)&lt;br /&gt;
 - dirty pages have to be &amp;quot;cleaned&amp;quot; (i.e., saved to disk) before they can be&lt;br /&gt;
   freed&lt;br /&gt;
 - we don&amp;#039;t want to kick out recently accessed pages as they are likely&lt;br /&gt;
   to be used in the future&lt;br /&gt;
    - we&amp;#039;d just have to load it back somewhere else, wasting time&lt;br /&gt;
 - when a program accesses parts of its virtual address space, the kernel&lt;br /&gt;
   has to make sure that memory is valid&lt;br /&gt;
     - if it is code, the code has to be loaded from disk&lt;br /&gt;
     - if data, have to make sure data page is allocated&lt;br /&gt;
 - the kernel can try to predict what a program is going to do&lt;br /&gt;
     - only makes sense in limited cases (e.g., load chunks of&lt;br /&gt;
       program binary from disk when program is first execve&amp;#039;d)&lt;br /&gt;
 - ideally, kernel would know exactly what each process would want to do next&lt;br /&gt;
    - would make sure resources were available just in time&lt;br /&gt;
    - of course, we can&amp;#039;t do this in practice&lt;br /&gt;
&lt;br /&gt;
 - note that block size on disk for current filesystems&lt;br /&gt;
   nowadays equals page size (both are 4k)&lt;br /&gt;
    - not essential but useful at times&lt;br /&gt;
    - we talk about blocks on disk, not pages (but that&amp;#039;s just terminology)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The memory hierarchy  (fastest storage-&amp;gt;slowest, smallest-&amp;gt;biggest)&lt;br /&gt;
&lt;br /&gt;
registers     &amp;lt;---  managed by the compiler&lt;br /&gt;
TLB           &amp;lt;---  managed by hardware, partially by OS&lt;br /&gt;
L1 cache      &amp;lt;---     (Per core)&lt;br /&gt;
L2 cache      &amp;lt;---  managed by CPU itself, no software involvement &lt;br /&gt;
L3 cache      &amp;lt;---     (Per CPU (chip))&lt;br /&gt;
&lt;br /&gt;
DRAM          &amp;lt;---  managed by OS&lt;br /&gt;
----------------  below is persistent, above, volatile, managed by software&lt;br /&gt;
ssd          &lt;br /&gt;
hard disks&lt;br /&gt;
tapes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L1, L2, and L3 are all caches of main memory (DRAM), are SRAM&lt;br /&gt;
 - vary in speed (latency/bandwidth in being transferred to registers)&lt;br /&gt;
 - vary in size (smaller vs larger)&lt;br /&gt;
&lt;br /&gt;
If you want to learn about architecture in more detail, read&lt;br /&gt;
Hennessey and Patterson, &amp;quot;Computer Architecture: A Quantitative Approach&amp;quot;&lt;br /&gt;
 - great book, very readable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Remember how we discussed concurrency was hard, required hardware support?&lt;br /&gt;
 - think about the work required to make sure copies in L1, L2, L3, registers,&lt;br /&gt;
   and DRAM are all in sync&lt;br /&gt;
     - can have 3, 4, or 5 copies of one variable, that logically should&lt;br /&gt;
       always be the same but in practice can get out of sync&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
you don&amp;#039;t have to make sure DRAM is in sync with the caches, that happens&lt;br /&gt;
automatically&lt;br /&gt;
  - it just isn&amp;#039;t perfect when you access DRAM in parallel from muliple cores,&lt;br /&gt;
    you can see (slightly) stale data&lt;br /&gt;
&lt;br /&gt;
The real secret of modern systems is that while we program mostly sequentially,&lt;br /&gt;
hardware runs things in parallel and *pretends* it all happened sequentially&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>