Title: Class 6: Making a Process (Virtualizing Memory)
Date: 2014-02-04
Category: Classes
Tags: operating systems, Rust, virtual memory, processes
Author: David Evans

   <div class="todo">
<center>
**[Problem Set 2](|filename|../../pages/ps/ps2/ps2.md)** is due Sunday, 9 February.  You should sign-up for a team demo using [this form](https://docs.google.com/spreadsheet/ccc?key=0AvXGI69lkg_edGE4dk0taUFlcmVueGg0UExIT1RZSXc&usp=sharing#gid=0).  
</center>
   </div>

## Slides

<center>
<iframe src="http://www.slideshare.net/slideshow/embed_code/30817159" width="476" height="400" frameborder="2" marginwidth="0" marginheight="0" scrolling="no"></iframe><br>
[Videos](https://www.youtube.com/playlist?list=PLvpsxlEF9cP3uR3DaskKygs0ToPGQktak)
</center>

# Gnashing about Gash

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/zhctErV4LSo?list=PLvpsxlEF9cP3uR3DaskKygs0ToPGQktak" frameborder="2" allowfullscreen></iframe>
</center>

Weilin's most evil test: 
````
   curl "http://rust-class.org/pages/ps2.html" | sed "s/[^a-zA-Z ]/ /g" | tr "A-Z " "a-z\n"| grep "[a-z]" | sort -u
````

What is the difference between a background process and foreground process?
<div class="gap">

</div>

What happens when the user types `Ctrl-C`?
<div class="gap">

</div>


# Memory Isolation

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/JR3MfAqFvWo?list=PLvpsxlEF9cP3uR3DaskKygs0ToPGQktak" frameborder="2" allowfullscreen></iframe>
</center>

How can a program be isolated in memory without hardware support?
<div class="gap">

</div>

[Native Client](https://developers.google.com/native-client/) - [_Native Client: A Sandbox for Portable, Untrusted x86 Native Code_](http://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/en/us/pubs/archive/34913.pdf), IEEE Security and Privacy ("Oakland") 2009.

What are the advantages/disadvantages of hardware-based memory isolation over software-based memory isolation?
<div class="gap">

</div>

# Implementing Virtual Memory

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/cwv9dvZuPzc?list=PLvpsxlEF9cP3uR3DaskKygs0ToPGQktak" frameborder="2" allowfullscreen></iframe>
</center>

Robert C. Daley and Jack B. Dennis, [_Virtual Memory, Processes, and Sharing in
MULTICS_](|filename|./daley-cacm68.pdf) - Symposium on Operating System
Principles (SOSP), 1967.

What must be done to switch processes on MULTICS?
<div class="gap">

</div>

# Virtual Memory on the x86

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/jkGZDb3100Q?list=PLvpsxlEF9cP3uR3DaskKygs0ToPGQktak" frameborder="2" allowfullscreen></iframe>
</center>

[Intel x86 Software Develop Manuals](http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf) - Most of what I covered today is in Volume I, Chapter 3 (_Basic Execution Environment_) with Section 3.3 on Memory Organization.  Chapter 5 is all about Protection.

Why is it useful to convert a _logical address_ into a _linear address_, as is done by the segmentation unit?
<div class="gap">

</div>

Where is the Global Descriptor Table stored?
<div class="gap">

</div>

Why is a memory page in the 80386 (32-bit) processor 4K bytes?
<div class="gap">

</div>

What will this program do and why?
````c
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
  char *s = (char *) malloc (1);
  int i = 0;
  while (1) {
    printf("%d: %x\n", i, s[i]);
    i += 4;
  }
}
````

**Challenge:** Write a program that takes _N_ as an input and produces
  (nearly) exactly _N_ page faults.  A good solution is worth a USS
  Hopper patch (even cooler than a Rust sticker!) or an exemption from
  Exam 1 or Exam 2.

If you were designing a modern processor today, and not limited by the
need to run legacy operating systems and programs, how would your memory
isolation design be different from x86's virtual memory?
<div class="gap">

</div>

# Growing a Language

Guy L. Steele's _Growing a Language_ [[Transcript](http://www.cs.virginia.edu/~evans/cs655/readings/steele.pdf)]: 
<center>
<iframe width="480" height="360" src="//www.youtube-nocookie.com/embed/_ahvzDzKdB0?rel=0" frameborder="0" allowfullscreen></iframe>
</center>

How well does the design of Rust espouse the philosophy of growing a
language by Guy Steele in the talk?  

<div class="gap">

</div>

<div id="disqus_thread"></div>

<script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'rust-class'; // required: replace example with your forum shortname
	var disqus_url = 'http://www.rust-class.org/class-6-making-a-process.html';

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>


