[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

1. Introduction

Welcome to Pintos. Pintos is a simple operating system framework for the 80x86 architecture. It supports kernel threads, loading and running user programs, and a file system, but it implements all of these in a very simple way. In the Pintos projects, you and your project team will strengthen its support in all three of these areas. You will also add a virtual memory implementation.

Pintos could, theoretically, run on a regular IBM-compatible PC. Unfortunately, it is impractical to supply every student a dedicated PC for use with Pintos. Therefore, we will run Pintos projects in a system simulator, that is, a program that simulates an 80x86 CPU and its peripheral devices accurately enough that unmodified operating systems and software can run under it. In this class we will use the QEMU simulator.

This chapter explains how to get started working with Pintos. You should read the entire chapter before you start work on any of the projects.


1.1 Getting Started

To get started, you'll have to log into a machine that Pintos can be built on. You can either (a) use our VirtualBox VM image with the necessary tools pre-installed, or (b) use your own machine and clone the files from our GIT repository.

1.1.1a Using the pre-installed VM image

Download our virtual machine image and import it using Virtual Box. It contains Ubuntu 18.04 LTS with the basic tools needed for the assignments. If you need to install additional packages, the default user, pintos has superuser permissions and password is pintos. Note that the keyboard is configured as US english.

When you have booted the Virtual Machine, you're ready to go. All you have to do is clone the git repository into /home/pintos/pintos:

# Switch to the home directory
$ cd ~/
# Clone the git GIT repository.
$ git clone https://gitlab.mpi-sws.org/operating-systems/assignments.git pintos

Before you can start commiting changes you will have to set your user name and email address in the git configuration:

$ git config --global user.name "My Name"
$ git config --global user.email "my-email@example.com"

1.1.1b Using your own machine

If you want to do the assignments on your own system, you need to setup the GIT repository:

# Create directory for pintos (of course you can use any path you want).
$ cd ~/
# Clone the git GIT repository.
$ git clone https://gitlab.mpi-sws.org/operating-systems/assignments.git pintos

Since PintOS needs to know where the kernel files are located, you have to set the environment variable PINTOSPATH. You can either manually set these variables every time you open a shell to work on the project, or you can add it to your shell configuration file (.bashrc for bash, .zshrc for zsh, or .profile for some other shells):

# Again, use the path where you created your GIT repository.
$ export PINTOSPATH=~/pintos/src
$ export PATH=$PATH:$PINTOSPATH/utils

You will also need to make sure that the necessary packages for builing and running pintos are installed. Our officially supported environment is based on Ubuntu 18.04, in which case the following packages are required for building and testing the assignments:

Other distributions and versions should work too, but you are on your own there. The git repository also contains a Dockerfile for our known to work ubuntu configuration that you can use as a reference.

1.1.2 Managing your GIT repository

In order to work in teams more efficiently, you're encouraged to use GIT. If you need a repository hosting service feel free to use Titania from UdS or other online services (GitHub, GitLab, Bitbucket, etc.).

To push commits to your online repository, you need to add it as a remote. In the following, replace <URL-TO-REPO> with the repository address (e.g., git@titania.fs.uni-saarland.de:os-ws19-myname.git):

# Add group's remote repository
$ git remote add mine <URL-TO-REPO>
# After that, subsequent commits can be pushed to the server.
$ git push -u mine master
# Likewise, commits at the server can be pulled to your local machines.
$ git fetch
$ git pull mine master

We cannot provide further support for installing and working on Pintos on your own machine, but you can find more instructions in section G. Installing Pintos.


1.1.3 Source Tree Overview

Let's take a look at what's inside. Here's the directory structure that you should see in pintos/src:

threads/
Source code for the base kernel, which you will modify starting in project 1.

userprog/
Source code for the user program loader, which you will modify starting with project 2.

vm/
An almost empty directory. You will implement virtual memory here in project 3.

filesys/
Source code for a basic file system. You will use this file system starting with project 2, but you will not modify it until project 4.

devices/
Source code for I/O device interfacing: keyboard, timer, disk, etc. You will modify the timer implementation in project 1. Otherwise you should have no need to change this code.

lib/
An implementation of a subset of the standard C library. The code in this directory is compiled into both the Pintos kernel and, starting from project 2, user programs that run under it. In both kernel code and user programs, headers in this directory can be included using the #include <...> notation. You should have little need to modify this code.

lib/kernel/
Parts of the C library that are included only in the Pintos kernel. This also includes implementations of some data types that you are free to use in your kernel code: bitmaps, doubly linked lists, and hash tables. In the kernel, headers in this directory can be included using the #include <...> notation.

lib/user/
Parts of the C library that are included only in Pintos user programs. In user programs, headers in this directory can be included using the #include <...> notation.

tests/
Tests for each project. You can modify this code if it helps you test your submission, but we will replace it with the originals before we run the tests.

examples/
Example user programs for use starting with project 2.

misc/
utils/
These files may come in handy if you decide to try working with Pintos on your own machine. Otherwise, you can ignore them.


1.1.4 Building Pintos

As the next step, build the source code supplied for the first project. First, cd into the threads directory. Then, issue the make command. This will create a build directory under threads, populate it with a Makefile and a few subdirectories, and then build the kernel inside. The entire build should take less than 30 seconds.

Watch the commands executed during the build. On the Linux machines, the ordinary system tools are used.

Following the build, the following are the interesting files in the build directory:

Makefile
A copy of pintos/src/Makefile.build. It describes how to build the kernel. See Adding Source Files, for more information.

kernel.o
Object file for the entire kernel. This is the result of linking object files compiled from each individual kernel source file into a single object file. It contains debug information, so you can run GDB (see section E.5 GDB) or backtrace (see section E.4 Backtraces) on it.

kernel.bin
Memory image of the kernel, that is, the exact bytes loaded into memory to run the Pintos kernel. This is just kernel.o with debug information stripped out, which saves a lot of space, which in turn keeps the kernel from bumping up against a 512 kB size limit imposed by the kernel loader's design.

loader.bin
Memory image for the kernel loader, a small chunk of code written in assembly language that reads the kernel from disk into memory and starts it up. It is exactly 512 bytes long, a size fixed by the PC BIOS.

Subdirectories of build contain object files (.o) and dependency files (.d), both produced by the compiler. The dependency files tell make which source files need to be recompiled when other source or header files are changed.


1.1.5 Running Pintos

We've supplied a program for conveniently running Pintos in a simulator, called pintos. In the simplest case, you can invoke pintos as pintos argument.... Each argument is passed to the Pintos kernel for it to act on.

Try it out. First cd into the newly created build directory. Then issue the command pintos run alarm-multiple, which passes the arguments run alarm-multiple to the Pintos kernel. In these arguments, run instructs the kernel to run a test and alarm-multiple is the test to run.

$ cd $PINTOSPATH/threads/build

$ make

$ pintos run alarm-multiple

By default, tests are run with the QEMU simulator and a new window opens that represents the simulated machine's display. Pintos boots and runs the alarm-multiple test program, which outputs program result. When the program is completed, you can close QEMU by simply closing the simulator's window or by pressing Ctrl-c at the terminal prompt.

(If no window appeared at all, then you're probably logged in remotely and X forwarding is not set up correctly. In this case, you can fix your X setup, or you can use the -v option to disable X output: pintos -v -- run alarm-multiple.)

You would have probably noticed by now that the text in the simulator window is also displayed in the terminal you used to run pintos. The first line in the terminal prompt looks similar to:

$ pintos run alarm-multiple

qemu -hda /tmp/kvS0tEGvzB.dsk -m 4 -net none -serial stdio

This indicates that Pintos sends all output to stdio and by default qemu's serial port is connected to stdio. You can log serial output to a file by redirecting at the command line as:

$ pintos run alarm-multiple > logfile.

The pintos program offers several options for configuring the simulator or the virtual hardware. If you specify any options, they must precede the commands passed to the Pintos kernel and be separated from them by --, so that the whole command looks like pintos option... -- argument.... Invoke

$ pintos

without any arguments to see a list of available options. Options can select a simulator to use: the default is QEMU, but you can run the tests with other simulators as follows. We only officially support Qemu.

You can run the simulator with a debugger (see section E.5 GDB) by specifying --gdb. You can set the amount of memory to give the VM. Finally, you can select how you want VM output to be displayed: use -v to turn off the VGA display, or -s to suppress serial input from stdin and output to stdout.

The Pintos kernel has commands and options other than run. These are not very interesting for now, but you can see a list of them using -h, e.g. pintos -h.


1.2 Grading

For most problems, we will grade your assignments primarily based on test results, but we will also evaluate the quality of your design decisions. However, for assignment 1, the second and third problems will be graded primarily based on code inspection.


1.2.1 Testing

Your test result grade will be primarily based on our tests. Each project has several tests, each of which has a name beginning with tests. To completely test your submission, invoke make check from the project build directory. This will build and run each test and print a "pass" or "fail" message for each one. When a test fails, make check also prints some details of the reason for failure. After running all the tests, make check also prints a summary of the test results.

You can also run individual tests one at a time. A given test t writes its output to t.output, then a script scores the output as "pass" or "fail" and writes the verdict to t.result. To run and grade a single test, make the .result file explicitly from the build directory, e.g. make tests/threads/alarm-multiple.result. If make says that the test result is up-to-date, but you want to re-run it anyway, either run make clean or delete the .output file by hand.

By default, each test provides feedback only at completion, not during its run. If you prefer, you can observe the progress of each test by specifying VERBOSE=1 on the make command line, as in make check VERBOSE=1. You can also provide arbitrary options to the pintos run by the tests with PINTOSOPTS='...', e.g. make check PINTOSOPTS='-s' to disable serial I/O.

All of the tests and related files are in pintos/src/tests. Before we test your submission, we will replace the contents of that directory by a pristine, unmodified copy, to ensure that the correct tests are used. Thus, you can modify some of the tests if that helps in debugging, but we will run the originals.

All software has bugs, so some of our tests may be flawed. If you think a test failure is a bug in the test, not a bug in your code, please let us know. We will look at it and fix it if necessary.

Please don't try to take advantage of our generosity in giving out our test suite. Your code has to work properly in the general case, not just for the test cases we supply. For example, it would be unacceptable to explicitly base the kernel's behavior on the name of the running test case. Such attempts to side-step the test cases will receive no credit. If you think your solution may be in a gray area here, please ask us about it.


1.2.2 Design

We will judge your design based on the design document and the source code that you submit. We will read your entire design document and much of your source code.


1.2.2.1 Design Document

We provide a design document template for each project. For each significant part of a project, the template asks questions in four areas:

Data Structures

The instructions for this section are always the same:

Copy here the declaration of each new or changed struct or struct member, global or static variable, typedef, or enumeration. Identify the purpose of each in 25 words or less.

The first part is mechanical. Just copy new or modified declarations into the design document, to highlight for us the actual changes to data structures. Each declaration should include the comment that should accompany it in the source code (see below).

We also ask for a very brief description of the purpose of each new or changed data structure. The limit of 25 words or less is a guideline intended to save your time and avoid duplication with later areas.

Algorithms

This is where you tell us how your code works, through questions that probe your understanding of your code. We might not be able to easily figure it out from the code, because many creative solutions exist for most OS problems. Help us out a little.

Your answers should be at a level below the high level description of requirements given in the assignment. We have read the assignment too, so it is unnecessary to repeat or rephrase what is stated there. On the other hand, your answers should be at a level above the low level of the code itself. Don't give a line-by-line run-down of what your code does. Instead, use your answers to explain how your code works to implement the requirements.

Synchronization

An operating system kernel is a complex, multithreaded program, in which synchronizing multiple threads can be difficult. This section asks about how you chose to synchronize this particular type of activity.

Rationale

Whereas the other sections primarily ask "what" and "how," the rationale section concentrates on "why." This is where we ask you to justify some design decisions, by explaining why the choices you made are better than alternatives. You may be able to state these in terms of time and space complexity, which can be made as rough or informal arguments (formal language or proofs are unnecessary).

An incomplete, evasive, or non-responsive design document or one that strays from the template without good reason may be penalized. Incorrect capitalization, punctuation, spelling, or grammar can also cost points. See section D. Project Documentation, for a sample design document for a fictitious project.


1.2.2.2 Source Code

Your design will also be judged by looking at your source code. We will typically look at the differences between the original Pintos source tree and your submission, based on the output of a command like diff -urpb pintos.orig pintos.submitted. We will try to match up your description of the design with the code submitted. Important discrepancies between the description and the actual code will be penalized, as will be any bugs we find by spot checks.

The most important aspects of source code design are those that specifically relate to the operating system issues at stake in the project. For example, the organization of an inode is an important part of file system design, so in the file system project a poorly designed inode would lose points. Other issues are much less important. For example, multiple Pintos design problems call for a "priority queue," that is, a dynamic collection from which the minimum (or maximum) item can quickly be extracted. Fast priority queues can be implemented many ways, but we do not expect you to build a fancy data structure even if it might improve performance. Instead, you are welcome to use a linked list (and Pintos even provides one with convenient functions for sorting and finding minimums and maximums).

Pintos is written in a consistent style. Make your additions and modifications in existing Pintos source files blend in, not stick out. In new source files, adopt the existing Pintos style by preference, but make your code self-consistent at the very least. There should not be a patchwork of different styles that makes it obvious that three different people wrote the code. Use horizontal and vertical white space to make code readable. Add a brief comment on every structure, structure member, global or static variable, typedef, enumeration, and function definition. Update existing comments as you modify code. Don't comment out or use the preprocessor to ignore blocks of code (instead, remove it entirely). Use assertions to document key invariants. Decompose code into functions for clarity. Code that is difficult to understand because it violates these or other "common sense" software engineering practices will be penalized.

In the end, remember your audience. Code is written primarily to be read by humans. It has to be acceptable to the compiler too, but the compiler doesn't care about how it looks or how well it is written.


1.3 Legal and Ethical Issues

Pintos is distributed under a liberal license that allows free use, modification, and distribution. Students and others who work on Pintos own the code that they write and may use it for any purpose. Pintos comes with NO WARRANTY, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See section License, for details of the license and lack of warranty.

In the context of the OS course, please refrain from reading any homework solutions available online or elsewhere. Reading the source code for other operating system kernels, such as Linux or FreeBSD, is allowed, but do not copy code from them literally. Please cite the code that inspired your own in your design documentation.


1.4 Acknowledgements

This document was adapted from the online Pintos documentation to meet the requirements of the Operating Systems course at Saarland University.

The Pintos core and this documentation were originally written by Ben Pfaff blp@cs.stanford.edu.

Additional features were contributed by Anthony Romano chz@vt.edu.

The GDB macros supplied with Pintos were written by Godmar Back gback@cs.vt.edu, and their documentation is adapted from his work.

The original structure and form of Pintos was inspired by the Nachos instructional operating system from the University of California, Berkeley ([ Christopher]).

The Pintos projects and documentation originated with those designed for Nachos by current and former CS 140 teaching assistants at Stanford University, including at least Yu Ping, Greg Hutchins, Kelly Shaw, Paul Twohey, Sameer Qureshi, and John Rector.

Example code for monitors (see section A.3.4 Monitors) is from classroom slides originally by Dawson Engler and updated by Mendel Rosenblum.


1.5 Trivia

Pintos originated as a replacement for Nachos with a similar design. Since then Pintos has greatly diverged from the Nachos design. Pintos differs from Nachos in two important ways. First, Pintos runs on real or simulated 80x86 hardware, but Nachos runs as a process on a host operating system. Second, Pintos is written in C like most real-world operating systems, but Nachos is written in C++.

Why the name "Pintos"? First, like nachos, pinto beans are a common Mexican food. Second, Pintos is small and a "pint" is a small amount. Third, like drivers of the eponymous car, students are likely to have trouble with blow-ups.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Björn Brandenburg on October, 22 2017 using texi2html