<?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_22</id>
	<title>Operating Systems 2019F Lecture 22 - 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_22"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2019F_Lecture_22&amp;action=history"/>
	<updated>2026-05-18T20:02:25Z</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_22&amp;diff=22544&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on November 27, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec22-20191127.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_22&amp;diff=22544&amp;oldid=prev"/>
		<updated>2020-03-20T02:11:10Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on November 27, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec22-20191127.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 November 27, 2019 [https://homeostasis.scs.carleton.ca/~soma/os-2019f/lectures/comp3000-2019f-lec22-20191127.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 22&lt;br /&gt;
----------&lt;br /&gt;
* assignment 4&lt;br /&gt;
* assignment 3 solutions&lt;br /&gt;
* virtualization &amp;amp; containers&lt;br /&gt;
&lt;br /&gt;
accepting questions on the #lecture channel&lt;br /&gt;
&lt;br /&gt;
Review session on Dec. 13th or 16th?  Please indicate your preferences on discord (thumbs up or down)&lt;br /&gt;
&lt;br /&gt;
Virtualization and containers&lt;br /&gt;
-----------------------------&lt;br /&gt;
&lt;br /&gt;
* on openstack and virtualbox, you are using &amp;quot;virtual machines&amp;quot;&lt;br /&gt;
* in CS, there are LOTS of virtual machines&lt;br /&gt;
  - simulation of another machine&lt;br /&gt;
  - that other machine may never be &amp;quot;real&amp;quot;&lt;br /&gt;
* for example, the Java Virtual Machine (JVM) has nothing to do&lt;br /&gt;
  with the VMs we get with virtualbox and openstack&lt;br /&gt;
&lt;br /&gt;
With hardware virtual machines&lt;br /&gt;
 - the virtual machine is roughly the same as the physical machine&lt;br /&gt;
 - so you can run a regular OS on the virtual machine (because it thinks&lt;br /&gt;
   it is running on real hardware)&lt;br /&gt;
&lt;br /&gt;
Key advantages of HVMs:&lt;br /&gt;
 - strong isolation&lt;br /&gt;
 - universality&lt;br /&gt;
&lt;br /&gt;
Key disadvantage of HVMs:&lt;br /&gt;
 - expensive!  you&amp;#039;re running lots of kernels&lt;br /&gt;
   (one per VM)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
processes (on one of the kernels)&lt;br /&gt;
Kernels * n&lt;br /&gt;
Hypervisor&lt;br /&gt;
Hardware&lt;br /&gt;
&lt;br /&gt;
Process is running on CPU, makes system call (software interrupt)&lt;br /&gt;
 - hardware recognizes event&lt;br /&gt;
 - hardware calls hypervisor handler for system call&lt;br /&gt;
 - hypervisor calls a kernel&amp;#039;s system call handler&lt;br /&gt;
 - kernel&amp;#039;s system call handler does the work, calls scheduler&lt;br /&gt;
 - hypervisor scheduler decides which kernel to next run, kernel&lt;br /&gt;
   schedule decides which process&lt;br /&gt;
&lt;br /&gt;
emulation versus virtualization&lt;br /&gt;
 - HVMs only interpose on system events, instructions run directly on CPU&lt;br /&gt;
 - emulators interpose on/translate every instruction&lt;br /&gt;
&lt;br /&gt;
You can use an HVM if the expected CPU architecture is the same;&lt;br /&gt;
emulation if they are different&lt;br /&gt;
 - so WINE really virtualizes, but MAME emulates&lt;br /&gt;
   (WINE is running x86 binaries on an x86 processor, while&lt;br /&gt;
    MAME may be running 6502 or ARM binaries on an x86 processor)&lt;br /&gt;
&lt;br /&gt;
Running multiple kernels on a hypervisor may be safer, but it is less efficient&lt;br /&gt;
&lt;br /&gt;
What you often want to do is to partition a system so it can run multiple&lt;br /&gt;
applications without them interfering with each other, while still trusting the binaries (they aren&amp;#039;t trying to attack each other)&lt;br /&gt;
&lt;br /&gt;
Contrast with a linux distribution&lt;br /&gt;
 - upgrade one package, it can break an arbitrary number of programs&lt;br /&gt;
 - dependencies help, but they only work when they are tested carefully&lt;br /&gt;
&lt;br /&gt;
Containers are a strategy for avoiding this work&lt;br /&gt;
&lt;br /&gt;
Basic idea: a container is everything in an OS *except* the kernel&lt;br /&gt;
 - all of userland&lt;br /&gt;
 - libraries, config files, binaries, data files&lt;br /&gt;
 - normally these are minimized so they are just enough for one application,&lt;br /&gt;
   but this is not strictly necessary&lt;br /&gt;
&lt;br /&gt;
Docker is just containers&lt;br /&gt;
&lt;br /&gt;
Docker is a bit tricky when running on a non-Linux system because it&lt;br /&gt;
has to supply its own Linux kernel (i.e., it will do hardware&lt;br /&gt;
virtualization under the containers).  A system running Linux natively&lt;br /&gt;
has no need to do this.&lt;br /&gt;
 - in theory you could have containers of MacOS or Windows userlands,&lt;br /&gt;
   but that just isn&amp;#039;t a thing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next time: containers from scratch&lt;br /&gt;
 - they are a pain but you can do it&lt;br /&gt;
&lt;br /&gt;
The problem with containers is security&lt;br /&gt;
 - UNIX/Linux kernels weren&amp;#039;t designed for this kind of separation&lt;br /&gt;
 - lots of ways containers can interfere with each other on the same machine&lt;br /&gt;
&lt;br /&gt;
In general, you should only run containers that you trust&lt;br /&gt;
&lt;br /&gt;
WebAssembly?  Have you heard of it or not?&lt;br /&gt;
&lt;br /&gt;
WebAssembly is a technology for running arbitrary programs inside a web page&lt;br /&gt;
 - use C, C++, Rust, whatever, inside of a web page&lt;br /&gt;
 - compile code to webassembly and the browser will run it&lt;br /&gt;
 - allows us to avoid JavaScript&lt;br /&gt;
&lt;br /&gt;
But...JavaScript is not trusted, but we normally trust the binaries we run&lt;br /&gt;
in other languages.&lt;br /&gt;
&lt;br /&gt;
JavaScript is sandboxed...using a language-based virtual machine&lt;br /&gt;
 - JavaScript code inherently can&amp;#039;t access your filesystem, other processes,&lt;br /&gt;
   etc - it can just make system calls&lt;br /&gt;
&lt;br /&gt;
WebAssembly gets it safety because its code runs inside the same JavaScript&lt;br /&gt;
sandbox&lt;br /&gt;
&lt;br /&gt;
This safety is so important it is moving beyond the web browser to servers&lt;br /&gt;
(meaning containers)&lt;br /&gt;
&lt;br /&gt;
Instead of compiling down to x86 or ARM, you&amp;#039;ll compile to WebAssembly and&lt;br /&gt;
run the binary anywhere - and the binary will be nicely sandboxed so everyone&lt;br /&gt;
is protected.&lt;br /&gt;
 - this solves the main limitation of containers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
WebAssembly is safe because of the lack of direct access to system calls&lt;br /&gt;
 - which says something about system calls&lt;br /&gt;
&lt;br /&gt;
system calls, even with users, groups, and permissions, are not that safe of an interface&lt;br /&gt;
 - not designed to prevent real malicious behavior&lt;br /&gt;
&lt;br /&gt;
so we&amp;#039;re moving away from system calls as the general abstraction for accessing&lt;br /&gt;
system resources&lt;br /&gt;
&lt;br /&gt;
So really in the future OS and web classes will have to merge&lt;br /&gt;
 - it will be all the same technology stack&lt;br /&gt;
 - but give it a decade, and still a conventional UNIX-like kernel will&lt;br /&gt;
   be there underneath it all&lt;br /&gt;
&lt;br /&gt;
And to be honest...I don&amp;#039;t think webassembly helps us much today in the browser,&lt;br /&gt;
because most of the code running there is user hostile (ads, tracking, miners)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>