CompSci 143A: Principles of Operating System
Instructor: Ardalan Amiri Sani |
Pintos Project Lab 0: Getting Real
This assignment is to prepare you for the later Pintos lab. You will mainly do a simple programming exercise to add a tiny kernel monitor to Pintos. Note that this assignment is simpler than the next lab as it is intentionally designed to help you warm up. This lab is borrowed from JHU's CS 318/418/618 course by Ryan Huang. Ryan borrwed part of this project's description and exercise from the MIT 6.828 and Caltech CS 124 course.Lab 0 Requirements
0. Project 0 Design Document
Before you turn in your project, you must copy the lab 0 design document
template into your source tree under the
name pintos/src/p0/DESIGNDOC
and fill it in.
1. Booting Pintos
Read the 1. Introduction section to get an overview of Pintos. Have Pintos development environment setup as described in Project Setup. Afterwards, execute
$ cd pintos/src/threads $ make $ cd build $ pintos --bochs -- run alarm-zero |
You can only use Bochs in Openlab (instructions above use Bochs).
Bochs will be useful for the 3. Project 1:
Threads.
If everything works, you should see Pintos booting in the Bochs emulator,
and print Execution of 'alarm-zero' complete.
near the end. In addition to the shell where
you execute the command, a new graphic window of Bochs will also pop up printing
the same messages. If you are remotely connecting to a machine, e.g., the
Openlab machines, you should make sure you use X window option in your SSH client so that the window can open.
If you have configured QEMU on your own machine, you can run Pintos with QEMU as follows.
$ cd pintos/src/threads $ make qemu |
If everything works, you should see Pintos booting in the QEMU
emulator,
and print Boot complete.
near the end. In addition to the shell where
you execute the command, a new graphic window of QEMU will also pop up printing
the same messages.
pintos/src/p0.
2. Kernel Monitor
At last, you will get to make a small enhancement to Pintos and write some code!
In particular, when Pintos finishes booting, it will check for the supplied
command line arguments stored in the kernel image. Typically you will pass
some tests for the kernel to run, e.g., pintos -- run alarm-zero
.
If there is no command line argument passed, the kernel will simply finish up.
This is a little boring. You task is to add a tiny kernel shell to Pintos
so that when no command line argument is passed, it will run this shell interactively.
Note that this is a kernel-level shell. In later projects, you will be enhancing
the user program and file system parts of Pintos, at which point you will get to
run the regular shell.
The code place for you to add this feature is in line 136 of
threads/init.c
with // TODO: no command line passed to kernel.
Run interactively
. You only need to make this monitor very simple. It starts with
a prompt ICS143A> and waits for user input. When a newline is entered, it
parses the input and checks if it is whoami. If it is whoami, print
your name. Afterwards, the monitor will print the command prompt ICS143A>
again in the next line and repeat. If the user input is exit, the monitor
will quit to allow the kernel to finish. For the other input, print
invalid command.
threads/init.cto implement a tiny kernel monitor in Pintos. Feel free to add new source files in to the Pintos code base for this task, e.g., provide a
readline
library function. Refer to
Adding
Source Files for how to
do so.
lib/kernel/console.c,
lib/stdio.cand
devices/input.c.