Title: Class 5: Gash Has No Privileges
Date: 2014-01-30
Category: Classes
Tags: operating systems, Rust, multi-tasking, shell
Author: David Evans

   <div class="todo">

**[Problem Set 2](|filename|../../pages/ps/ps2/ps2.md)** is now posted,
  and is due Sunday, 9 February.  You should be making good progress on
  it by now.  

[Part
  3](http://aml3.github.io/RustTutorial/html/03.html#Multi-Purpose_Maps:<br>Structures,_Traits,_and_Higher-Order_Functions)
  and [Part
  4](http://aml3.github.io/RustTutorial/html/04.html#Tasks_and_Communication)
  of the Rust tutorial should be helpful in understanding some of the
  things for PS2.
   </div>

## Slides

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

# Kernels and Privileges

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

What can kernel code do that user-level programs cannot?
<div class="gap">

</div>


What instructions need to be privileged and why?
<div class="gap">

</div>

# Virtualization

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

How is it possible to run and OS as a user-level program?
<div class="gap">

</div>



# Building a Better Broswer

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

_Should a browser be creating 1, 2, 43 or 153 processes on your machine?_ 

The way engineers should answer questions like this is to think about **tradeoffs**: do the benefits outweigh the costs?  

For most problems in computing, the answer changes about every 10 years.
(Why every 10 years?  If computing power increases according to Moore's
Observation, 10 years is enough time for a 50<em>x</em> improvement.  It
would be really surprising if the relative costs and benefits of things
don't change dramatically when the underlying technology cost changes by
50<em>x</em>.)

In the 1990s, memory was very expensive (relative to today), and
unnecessary processes waste lots of memory.  Using one process for the
browser was the right answer.  By the 2000s, memory was getting cheap
enough that it was worth using lots of memory to build a more robust and
secure browser.  When Google introduced the Chrome browser in 2008, they
did it using a [really fantastic comic
book!](http://www.google.com/googlebooks/chrome/) This book covers
essentially all of the topics we will cover in this class, and has the
added benefits of having funny pictures.

_If one process per tab was the correct answer in 2008, surely the answer should have changed by now?_

Humans shouldn't waste their precious time and get grumpy waiting for JavaScript programs to finish running in their web browser while useful computing resources sitting idle because your browser is too stupid to be able to use more than one process for the active page!

There's one big problem: browsers are big, complicated programs and changing how they use processes is not something to be done lightly.
Its even worse (and effectively impossible) if you are using programming tools that dropped the useful features of pre-1960s languages in order to fit into the limited memory of machines available to researchers at Bell Labs in the late 1960s.

If you want to robustly and securely divide the work of rendering a web
page across multiple cores, you want it to run in multiple threads (not
separate processes since they do need to communicate frequently).  For
this, we need programming tools that make safe concurrency (relatively)
easy.  This is the main reason Rust is being developed: Mozilla wants to
build a better browser that can use modern computers more efficiently,
but didn't think this was possible using C++.

For more on Servo: [_Samsung teams up with Mozilla to build browser
engine for multicore
machines_](http://arstechnica.com/information-technology/2013/04/samsung-teams-up-with-mozilla-to-build-browser-engine-for-multicore-machines/),
arstechnica, 3 April 2013.


## Gash Demo

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/GtPWXuBMJYA?rel=0" frameborder="2" allowfullscreen></iframe>
</center>

What happened when I killed gash?
<div class="gap">

</div>

In which x86 ring does gash run?
<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-5-gash-has-no-privileges.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>
