<?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_2015F_Lecture_13</id>
	<title>Operating Systems 2015F Lecture 13 - 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_2015F_Lecture_13"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2015F_Lecture_13&amp;action=history"/>
	<updated>2026-05-01T05:38:15Z</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_2015F_Lecture_13&amp;diff=20349&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  The video for the lecture given on October 21, 2015 [http://homeostasis.scs.carleton.ca/~soma/os-2015f/lectures/comp3000-2015f-lec13-21Oct2015.mp4 is now available]...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2015F_Lecture_13&amp;diff=20349&amp;oldid=prev"/>
		<updated>2015-10-21T19:04:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  The video for the lecture given on October 21, 2015 [http://homeostasis.scs.carleton.ca/~soma/os-2015f/lectures/comp3000-2015f-lec13-21Oct2015.mp4 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;
The video for the lecture given on October 21, 2015 [http://homeostasis.scs.carleton.ca/~soma/os-2015f/lectures/comp3000-2015f-lec13-21Oct2015.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
Project&lt;br /&gt;
 - know what you are curious about&lt;br /&gt;
 - digging into the kernel&lt;br /&gt;
&lt;br /&gt;
Interview&lt;br /&gt;
 - purpose: are you hacking the kernel&lt;br /&gt;
 - test of how bloody are your knuckles&lt;br /&gt;
 - don&amp;#039;t talk to me until you&amp;#039;ve spent at least 10 hours on your own looking at code (outside of tutorial)&lt;br /&gt;
 - for example, what code runs when I press a key?&lt;br /&gt;
 - pass/fail (100 or 0) - and you can come back&lt;br /&gt;
 - you can come in starting NOW&lt;br /&gt;
 - I am available Wednesday and Friday during the break&lt;br /&gt;
 - email to make an appointment, giving at least 3 times you can come in for 15-30 minutes.&lt;br /&gt;
 - after, Mondays and Tuesdays are best&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Virtual Memory&lt;br /&gt;
 - TLB stores a cache of virtual to physical address mappings&lt;br /&gt;
   - cache of WHAT&lt;br /&gt;
 - need a data structure that maps an entire address space (2^32 or 2^64) memory locations.&lt;br /&gt;
    - virtual and physical address space may be different&lt;br /&gt;
    - generally you have less physical memory than virtual memory,&lt;br /&gt;
      so can use fewer bits in physical addresses&lt;br /&gt;
      - for 64 bit systems, physical addresses are like 48 bits&lt;br /&gt;
        or a few more&lt;br /&gt;
    - but sometimes you get physical addresses that are larger that virtual addresses&lt;br /&gt;
  - apple 2&amp;#039;s had an 8 bit processor with 16 bit addresses&lt;br /&gt;
     - to address more than 64K, you did &amp;quot;bank switching&amp;quot;,&lt;br /&gt;
       one set of 16K addresses were mapped onto arbitrary banks of upper memory, using a &amp;quot;selector&amp;quot; address.&lt;br /&gt;
  - for 32 bit addresses, that&amp;#039;s 4G of RAM&lt;br /&gt;
     - intel makes processors with extensions to access more ram (PAE)&lt;br /&gt;
     - each process is limited to 4G, but kernel deals with mess of extra RAM&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  - mapping memory is expensive, do it in chunks&lt;br /&gt;
    - should the chunks be variable or fixed sized?&lt;br /&gt;
    - variable sized chunks are too hard to pack&lt;br /&gt;
        (segments, with a base address and a bound address)&lt;br /&gt;
	segments are still used in executable file formats&lt;br /&gt;
	and for setting permissions on ranges of memory&lt;br /&gt;
	(sometimes)&lt;br /&gt;
    - fixed sized chunks of memory are pages&lt;br /&gt;
       4K or 8K&lt;br /&gt;
       sometimes really big (2M), for mapping video memory&lt;br /&gt;
    - pages are loaded into memory frames in RAM&lt;br /&gt;
&lt;br /&gt;
  - map pages to frames (equal size)&lt;br /&gt;
  - mapping data structure needs to be sparse&lt;br /&gt;
     - not use memory for unallocated areas&lt;br /&gt;
  - must store data structure in a set of pages&lt;br /&gt;
  - this is a page table&lt;br /&gt;
     - but it is really a tree&lt;br /&gt;
&lt;br /&gt;
  - leaves are data pages&lt;br /&gt;
  - nodes are pages&lt;br /&gt;
  - each internal node is an array of page table entries (PTEs)&lt;br /&gt;
    - evenly fit into page of course&lt;br /&gt;
&lt;br /&gt;
  - with 32 bit addresses and a 4K page&lt;br /&gt;
     - [ virt page # ][ offset #] = virtual address&lt;br /&gt;
     - offset is used to index into actual page&lt;br /&gt;
     - virt page # is used to walk page table&lt;br /&gt;
     - how many bits?  12 bits for offset, 20 for virt page #&lt;br /&gt;
&lt;br /&gt;
     - page table has to map 2^20 =&amp;gt; 2^20&lt;br /&gt;
     - physical address = [ frame # ][ offset #]&lt;br /&gt;
       - to translate, map page to frame number and copy offset&lt;br /&gt;
     - PTE = [ frame # ][ metadata ]&lt;br /&gt;
       - frame # is 20 bits, 12 bits of metadata&lt;br /&gt;
       - takes up 32 bits&lt;br /&gt;
     - how many PTEs in a page?  4096 bytes per page/&lt;br /&gt;
                                 4 bytes per PTE&lt;br /&gt;
				 = 1024 PTEs in a page&lt;br /&gt;
     - tree has 2 levels.  Top node and middle nodes&lt;br /&gt;
       - top node has 1024 &amp;quot;pointers&amp;quot; (PTEs)&lt;br /&gt;
       - middle nodes each have 1024 PTEs, each referring to data&lt;br /&gt;
         or code pages&lt;br /&gt;
       - note any PTE may be marked as &amp;quot;not present&amp;quot;&lt;br /&gt;
     - So for a 4K of address space, you need 3 pages (12K)&lt;br /&gt;
       - 1 top, 1 middle, and 1 data&lt;br /&gt;
&lt;br /&gt;
  - why care?&lt;br /&gt;
    - page tables are managed by the kernel&lt;br /&gt;
      - specifically, every process has its own page table&lt;br /&gt;
        (virtual memory mapping)&lt;br /&gt;
&lt;br /&gt;
  - what metadata is stored in a PTE&lt;br /&gt;
    - permissions (read, write, exec)&lt;br /&gt;
    - valid?  (allocated memory?)&lt;br /&gt;
    - present? (in RAM?)&lt;br /&gt;
    - dirty? (has it been modified since loaded)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>