ECE.6502020-08-04T08:01:37-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19Arie Gurfinkelarie.gurfinkel@uwaterloo.caConcurrency2019-11-07T00:00:00-05:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/11/07/concurrency
<p>Additional references for the material on concurrency programming</p>
<h2 id="modern-operating-systems-by-andrew-s-tanenbaum">Modern Operating Systems by Andrew S. Tanenbaum</h2>
<p><a href="https://github.com/concerttttt/books/blob/master/Modern%20Operating%20Systems%204th%20Edition--Andrew%20Tanenbaum.pdf">Book</a></p>
<h2 id="operating-system-concepts-by-avi-silberschatz">Operating System Concepts by Avi Silberschatz</h2>
<p><a href="https://learning.oreilly.com/library/view/operating-system-concepts/9780470128725/silb_9780470128725_oeb_c04_r1.html">Pthreads</a></p>
<p><a href="https://learning.oreilly.com/library/view/operating-system-concepts/9780470128725/silb_9780470128725_oeb_c03_r1.html">Shared Memory</a></p>
Learning Python2019-09-13T00:00:00-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/09/13/python
<h2 id="learning-python">Learning Python</h2>
<p>In the next lecture, we will review basic Python programming. If you
are new to programming and/or new to Python, there are many online
tutorials to get you started. I expect you to go over at least one of
the tutorials suggested below before the next class.</p>
<p><em>Note that there are two active version of Python: Python2 and
Python3. We will be using the most established Python2 version 2.7 in
class. While there are some significant difference between the
versions, it is quite easy to migrate between them. However, when
looking for references online, make sure that they refer to Python
version 2!</em></p>
<h2 id="suggested-python-references-and-tutorials">Suggested Python References and Tutorials</h2>
<ul>
<li>
<p><a href="https://docs.python.org/2/">The Official Python Documentation</a>. Everything
that you ever need to know about Python can be found here.</p>
</li>
<li>
<p><a href="https://docs.python.org/2/tutorial/index.html">The Official Python Tutorial</a>. A
step-by-step guide through all the Python features.</p>
</li>
<li>
<p><a href="https://www.learnpython.org/">Interactive Python Tutorial</a>. Learn
Python directly in your browser!</p>
</li>
<li>
<p><a href="http://greenteapress.com/wp/think-python/">Think Python</a>. A freely
available book on Python.</p>
</li>
<li>
<p><a href="http://www.pythontutor.com">Python Tutor</a>. Learn Python by
visualizing what happens on the inside.</p>
</li>
<li>
<p><a href="http://www.diveintopython.net/">Dive into Python</a>. A freely
available book on Python2.</p>
</li>
<li>
<p><a href="https://stackoverflow.com">Stackoverflow</a>. Answers to all
programming questions in all languages.</p>
</li>
</ul>
Learning C++2019-09-13T00:00:00-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/09/13/c-plus-plus
<h2 id="learning-c">Learning C++</h2>
<p>A significant portion of the course involves programming in
C++. However, our emphasis is on systems programming and not on C++.
Students that feel comfortable using advanced C++ future should do
so. However, if you feel overwhelmed with the many ways to program in
C++, the complexity of the standard library, and many potential
designs, use the bare minimum. All of the assignments can be done in C
and do not rely on advanced knowledge of any programming language.</p>
<h2 id="suggested-c-references-and-tutorials">Suggested C++ References and Tutorials</h2>
<ul>
<li>
<p><a href="https://ece.uwaterloo.ca/~dwharder/aads/Tutorial/">C++ Tutorial from Douglas Harder</a>. Everything
you need to know about C and C++ to get started.</p>
</li>
<li>
<p><a href="http://www.cplusplus.com/">cplusplus.com</a>. A large collection of
tutorials and references covering many aspects of C++.</p>
</li>
<li>
<p><a href="http://en.cppreference.com/w/">C++ Reference</a>. A reference for
language specification and standard library. A subset of
cplusplus.com, but sometimes better formatted</p>
</li>
<li>
<p><a href="https://www.amazon.ca/Primer-5th-Stanley-B-Lippman/dp/0321714113">C++ Primer</a>. One
of the many excellent C++ books. Note that you do not need a C++
book for the course.</p>
</li>
<li>
<p><a href="http://www.toves.org/books/cpy/">C for Python Programmers</a>. Many of
the differences between Python and C are also applicable to C++.</p>
</li>
<li>
<p><a href="https://stackoverflow.com">Stackoverflow</a>. Answers to all
programming questions in all languages.</p>
</li>
</ul>
Setting up Windows Subsystem for Linux2019-09-07T00:00:00-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/09/07/wsl
<h2 id="windows-subsystem-for-linux-wsl">Windows Subsystem for Linux (WSL)</h2>
<p>WSL can be used to install Ubuntu distribution on Windows. Installation guide
can be found <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10">here</a>.</p>
<h2 id="install-required-packages">Install required packages</h2>
<pre><code>$ sudo apt install python build-essential git cmake nano gedit ipython gdb
</code></pre>
<h2 id="access-windows-system">Access Windows System</h2>
<p>Windows directories can be accessed under the <code>/mnt</code> directory. For example
inside of a shell window, use this to get to the Desktop directory:</p>
<pre><code>$ cd /mnt/c/Users/user_name/Desktop/
</code></pre>
<p>Change the <code>user_name</code> to the actual username for the pc</p>
<h2 id="open-file-exlporer-from-terminal">Open File exlporer from terminal</h2>
<p>Windows File explorer can be opened from the ubuntu terminal using the following command.</p>
<pre><code>$ explorer.exe .
</code></pre>
Using SSH from Windows2019-09-07T00:00:00-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/09/07/ssh
<p>This tutorial describes how to connect to <code>eceubuntu</code> machines from Windows.</p>
<h2 id="putty">PuTTY</h2>
<p>PuTTY is a free SSH and telnet client for Windows that allows remote access to the another computer. We can use PuTTY to connect to the <code>eceubuntu</code> machines.</p>
<h2 id="get-putty-for-windows">Get PuTTY for Windows</h2>
<p>Package files for PuTTY can be downloaded from <a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html">here</a></p>
<h2 id="connect-to-ece-linux-machines">Connect to ECE Linux Machines</h2>
<ul>
<li>When the software starts, you should get a window with the title PuTTY Configuration with a field <code>Host Name</code> in the upper middle part.</li>
<li>Try entering a host name <code>USER@eceTerm.uwaterloo.ca</code> or <code>USER@eceLinux4.uwaterloo.ca</code> (Replace <code>USER</code> with your watiam id) to connect to in that field, and click Open.</li>
<li>Then, it will prompt for password, enter your watiam password.</li>
<li>You may <a href="https://ece.uwaterloo.ca/~agurfink/ece650/tutorial/2019/08/25/virtualenv-intro">setup virtualenv</a>.</li>
</ul>
Setting up Docker2019-09-06T00:00:00-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/09/06/docker
<h2 id="what-is-docker">What is Docker?</h2>
<p>The easiest way of thinking about Docker is to think about it as a lightweight virtual machine
(in case of running Docker on Windows or MacOS, it is actually the correct way of thinking). Docker gives you a separated running environment you can mess around with without ruining your OS.</p>
<h2 id="how-to-install-docker">How to install Docker?</h2>
<h3 id="linux-ubuntu-based">Linux (Ubuntu based)</h3>
<p>You can read the full guide [here] (https://docs.docker.com/install/linux/docker-ce/ubuntu/)</p>
<p>I highly recommend you to follow the <code>Install using the repository</code> instruction.</p>
<p>After installation, remember to do <a href="https://docs.docker.com/install/linux/linux-postinstall/">this</a></p>
<h3 id="macos">MacOS</h3>
<p>Follow <a href="https://docs.docker.com/docker-for-mac/install/">this</a></p>
<h3 id="windows">Windows</h3>
<p>Follow <a href="https://docs.docker.com/docker-for-windows/install/">this</a></p>
<p>Please make sure that you read the <code>System requirements</code> carefully.</p>
<h2 id="how-to-use-docker">How to use Docker?</h2>
<p>For this part, I assume that on my local machine, my work directory is
`
/home/levn/workspace/ece650/
`</p>
<p>and I want to map it to
`
/home/ece650
`
in my container.</p>
<h3 id="get-the-image-for-the-course">Get the image for the course</h3>
<p><code>docker pull levn/ece650base</code></p>
<h3 id="create-a-container-think-about-it-as-a-virtual-machine-using-the-downloaded-image">Create a container (think about it as a virtual machine) using the downloaded image</h3>
<p><code>docker run -dit -v /home/levn/workspace/ece650/:/home/ece650/ --name ECE650 levn/ece650base</code></p>
<p>Explanation:</p>
<ul>
<li><code>docker run</code> is the command to create a container</li>
<li><code>-dit</code> is to <code>detach</code> the screen</li>
<li><code>-v</code> is to map a folder on your machine with a folder inside the container (virtual machine). This is crucial because we want to edit files in our machine using our fancy IDE, and run the exact same files inside the container.</li>
<li><code>-name</code> is to name the container so that we can access it later easily</li>
</ul>
<h3 id="verify-that-the-container-virtual-machine-is-created">Verify that the container (virtual machine) is created</h3>
<p><code>docker ps</code></p>
<p>You should see somethings like</p>
<pre><code>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1d76bdabed24 levn/ece650base "/bin/bash" 8 minutes ago Up 7 minutes ECE650
l
</code></pre>
<h3 id="use-the-container">Use the container</h3>
<p>Run</p>
<p><code>docker exec -it ECE650 /bin/bash</code></p>
<p>You will see your prompt turn into something like</p>
<p><code>root@bce6b727fb8e</code></p>
<p>, indicating that you are now inside the container as <code>root</code>.
Now you can go to the work directory</p>
<p><code>
cd /home/ece650
</code></p>
<p>and you can try to create an empty file.</p>
<p><code>
touch hello.txt
</code></p>
<h3 id="exit-the-container">Exit the container</h3>
<p>Type</p>
<p><code>
exit
</code></p>
<p>Now in your local machine, you should see the prompt returns to normal, indicating that you are now out of the container.</p>
<p>You should also be able to find the file <code>hello.txt</code> in <code>/home/levn/workspace/ece650</code> as well.</p>
Setting up virtualenv2019-08-25T00:00:00-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/08/25/virtualenv-intro
<p>This tutorial describes how to setup <code>virtualenv</code> on <code>eceubuntu</code>. If
your are installing it in another environment, skip up to <em>Creating
virtualenv</em> step.</p>
<h2 id="ece-ubuntu-machines">ECE Ubuntu Machines</h2>
<p>To login to these machines use <code>eceubuntu.uwaterloo.ca</code>.
When working remotely, first login to <code>ecelinux4.uwaterloo.ca</code> or <code>eceterm.uwaterloo.ca</code>
and then to one of the machines above. For example</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span></span>$ ssh user@eceterm.uwaterloo.ca
$ ssh user@eceubuntu.uwaterloo.ca</code></pre></figure>
<h2 id="ece-linux-machines">ECE Linux Machines</h2>
<p><strong>These are instructions for old machines. Do not use.</strong>*</p>
<p>There are 8 linux machines available:
<code>ecelinux[1-8].uwaterloo.ca</code>. The instructions have been tested on the
newer machines <code>ecelinux[1-3].uwaterloo.ca</code>. Please use those machines
only. When working remotely, first login to <code>ecelinux4.uwaterloo.ca</code>
and then to one of the machines above. For example</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span></span>$ ssh user@ecelinux4.uwaterloo.ca
$ ssh user@eceubuntu.uwaterloo.ca</code></pre></figure>
<h2 id="create-virtualenv-space-for-the-course">Create virtualenv space for the course</h2>
<p>Detailed instructions are available
at
<a href="http://docs.python-guide.org/en/latest/dev/virtualenvs">http://docs.python-guide.org/en/latest/dev/virtualenvs</a></p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span></span>$ mkdir ece650
$ <span class="nb">cd</span> ece650
$ virtualenv venv</code></pre></figure>
<p>Activate virtualenv (this needs to be done at every login to use the
environment)</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span></span>$ <span class="nb">source</span> ./venv/bin/activate
<span class="o">(</span>venv<span class="o">)</span> <span class="o">[</span>user@eceubuntu ece650<span class="o">]</span>$</code></pre></figure>
<h2 id="install-required-packages">Install required packages</h2>
<p>You might find it convenient to use
the <a href="https://coverage.readthedocs.io/en/coverage-4.2/">coverage</a>
package to evaluate the quality of your testing.</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span></span>$ <span class="nb">source</span> ./venv/bin/activate
$ pip install coverage</code></pre></figure>
<p>To de-active the environment</p>
<pre><code>(venv) [user@eceubuntu ece650]$ deactivate
</code></pre>
<h2 id="to-activate-and-deactivate-virtualenv-during-each-login-session">To activate and deactivate virtualenv during each login session</h2>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span></span>$ <span class="nb">source</span> ./venv/bin/activate
<span class="o">(</span>venv<span class="o">)</span> $ coverage --help
<span class="o">(</span>venv<span class="o">)</span> $ deactivate
$</code></pre></figure>
<p>After <code>virtualenv</code> is activated you should be able to use <code>python</code>,
<code>coverage</code>, <code>ipython</code>, and other python commands as usual.</p>
Setting up VirtualBox2019-08-25T00:00:00-04:00https://ece.uwaterloo.ca/~agurfink/ece650.f19/tutorial/2019/08/25/virtual-box
<p>You may find it convenient to work on assignments locally. This is
easy if your local machine is running Linux. If not, you can use a
Virtual Machine with Ubuntu 16.04. This is a quick tutorial to get you
started.</p>
<h2 id="get-virtualbox">Get VirtualBox</h2>
<p>There are many VM software packages available. A common one is called
VirtualBox. It is available from <a href="https://www.virtualbox.org/">here</a>.</p>
<h2 id="get-ubuntu">Get Ubuntu</h2>
<p>Ubuntu and installation instructions are available
from <a href="https://www.ubuntu.com">here</a>.</p>
<p>However, it is easier to use a pre-build VirtualBox image. There are
many images available on the web. For example,
<a href="http://www.osboxes.org/ubuntu//#ubuntu-16-04-vbox">http://www.osboxes.org/ubuntu//#ubuntu-16-04-vbox</a>. Make
sure you get the image for version <strong>16.04</strong>. Usually, 32bit VMs are a
bit faster. You might need <a href="http://www.7-zip.org/">7-zip</a> to unpack
the disk image.</p>
<p>The username and password are the same for the downloaded image.</p>
<p>To install, create a new virtual machine in VirtualBox and choose <em>Use
an existing virtual hard disk file</em> option.</p>
<h2 id="install-required-packages">Install required packages</h2>
<p>In the virtual machine, open a terminal and install required packages:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span></span>$ sudo apt install build-essential git cmake nano gedit ipython gdb</code></pre></figure>