<?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_11</id>
	<title>Operating Systems 2015F Lecture 11 - 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_11"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2015F_Lecture_11&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_11&amp;diff=20326&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  The video for the lecture given on October 14, 2015 [http://homeostasis.scs.carleton.ca/~soma/os-2015f/lectures/comp3000-2015f-lec11-14Oct2015.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_11&amp;diff=20326&amp;oldid=prev"/>
		<updated>2015-10-14T19:03:52Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  The video for the lecture given on October 14, 2015 [http://homeostasis.scs.carleton.ca/~soma/os-2015f/lectures/comp3000-2015f-lec11-14Oct2015.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 14, 2015 [http://homeostasis.scs.carleton.ca/~soma/os-2015f/lectures/comp3000-2015f-lec11-14Oct2015.mp4 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 11&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
 - ftrace&lt;br /&gt;
 - virtual memory&lt;br /&gt;
&lt;br /&gt;
Ftrace&lt;br /&gt;
------&lt;br /&gt;
 - as root, go into /sys/kernel/debug&lt;br /&gt;
 - enable events that you want by doing an echo &amp;quot;1&amp;quot; to the &amp;quot;enable&amp;quot; file for the event you want, e.g. events/syscalls/sys_enter_chdir/enable&lt;br /&gt;
 - look at the events in trace or, to just get the most recent ones, attach to trace_pipe&lt;br /&gt;
 - be sure to do an echo &amp;quot;0&amp;quot; to the enable file when you are done!&lt;br /&gt;
&lt;br /&gt;
For a tutorial on ftrace, see lwn.net:&lt;br /&gt;
  https://lwn.net/Articles/365835/  (Part 1)&lt;br /&gt;
  https://lwn.net/Articles/366796/  (Part 2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Virtual memory&lt;br /&gt;
--------------&lt;br /&gt;
 - remember the kernel is LAZY&lt;br /&gt;
   - defers I/O for as long as possible, in general&lt;br /&gt;
 - &amp;quot;mapped&amp;quot; files are only loaded into memory logically at the time of the mmap&lt;br /&gt;
 - file I/O only happens when assocatied memory is accessed (read or write)&lt;br /&gt;
   - loads in blocks of course&lt;br /&gt;
   - data is loaded &amp;quot;on demand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 - kernel is also lazy about memory allocation&lt;br /&gt;
 - consider fork&lt;br /&gt;
   - logically, copies a process&amp;#039;s entire address space&lt;br /&gt;
   - often, though, that address space is quickly discarded&lt;br /&gt;
     (when you do an execve)&lt;br /&gt;
   - solution: only copy data *as needed*&lt;br /&gt;
     - called &amp;quot;copy on write&amp;quot;, or COW&lt;br /&gt;
&lt;br /&gt;
 - kernel memory management is about using RAM to maximum effect&lt;br /&gt;
   - for files that are being currently accessed&lt;br /&gt;
     - only the part of those files that are being accessed&lt;br /&gt;
   - only code and data of processes that is actually being used&lt;br /&gt;
&lt;br /&gt;
 - why is this hard&lt;br /&gt;
   - what does &amp;quot;current&amp;quot; actually mean?&lt;br /&gt;
   - when is stuff used recently not going to be used again?&lt;br /&gt;
     - past predicts the future, but not always&lt;br /&gt;
&lt;br /&gt;
 - computer memory is designed assuming locality of various kinds&lt;br /&gt;
   - temporal locality&lt;br /&gt;
      - access in the past means likely access in the future&lt;br /&gt;
   - spatial locality (closer together data is more likely to be&lt;br /&gt;
                       accessed at the same time)&lt;br /&gt;
&lt;br /&gt;
   - code and data exhibit different locality patterns&lt;br /&gt;
     e.g. video streaming&lt;br /&gt;
       - run the same code over and over again&lt;br /&gt;
       - data is accessed once then discarded&lt;br /&gt;
&lt;br /&gt;
   - to take advantage of locality patterns, we have a memory hierarchy&lt;br /&gt;
     - different types of memory, with different characteristics:&lt;br /&gt;
       - volatility&lt;br /&gt;
       - size&lt;br /&gt;
       - latency of access&lt;br /&gt;
       - bandwidth&lt;br /&gt;
&lt;br /&gt;
   - most obvious: disk and RAM&lt;br /&gt;
     - disk is slow, but durable&lt;br /&gt;
     - RAM is fast but ephemeral&lt;br /&gt;
&lt;br /&gt;
   - latency versus bandwidth&lt;br /&gt;
     - in general, you want low latency and high bandwidth&lt;br /&gt;
       - latency: time to get first byte of data&lt;br /&gt;
       - bandwidth: rate of data transfer over time&lt;br /&gt;
     - you can easily increase bandwidth by increasing parallelism&lt;br /&gt;
     - you have to design for latency&lt;br /&gt;
&lt;br /&gt;
   - but real hierarchy is deeper&lt;br /&gt;
     - CPU registers&lt;br /&gt;
     - TLB, translation lookaside buffer&lt;br /&gt;
        - cache of virtual to physical memory mappings&lt;br /&gt;
	- it is an associative array implemented in hardware&lt;br /&gt;
     - L1 cache (smallest, lowest latency)&lt;br /&gt;
     - L2 cache (larger, moderate latency)&lt;br /&gt;
     - L3 cache (even larger, higher latency, but still faster than DRAM)&lt;br /&gt;
     - DRAM (pretty big, high latency, high bandwidth)&lt;br /&gt;
     - Solid state disks (flash memory)&lt;br /&gt;
     - Hard disks (spinning)&lt;br /&gt;
     - Tape&lt;br /&gt;
&lt;br /&gt;
   - virtual versus physical addresses&lt;br /&gt;
     - programs access memory in terms of virtual addresses&lt;br /&gt;
     - storage happens with physical addresses&lt;br /&gt;
     - virtual to physical address translation happens&lt;br /&gt;
       ON EVERY MEMORY ACCESS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>