$19
In this lab you will implement user processes and system calls.
As supplied, Pintos is incapable of running user processes and only implements two systems calls. Pintos does, however, have the ability to load ELF binary executable, and has a fully functioning page-based, non-virtual memory management system.
There are three parts to this lab; each depends on the previous one.
Setup
SSH in to one of the two CMPS111 teaching servers using your CruzID Blue password:
Or |
$ ssh |
<cruzid>@noggin.soe.ucsc.edu |
( use Putty http://www.putty.org/ if on Windows ) |
||
$ ssh |
<cruzid>@nogbad.soe.ucsc.edu |
|
|
|
|
Authenticate with Kerberos and AFS:
$ kinit
$ aklog
Create a suitable place to work: ( only do this the first time you log in )
$ mkdir –p ~/CMPS111/Lab3
$ cd ~/CMPS111/Lab3
Install the lab environment: ( only do this once )
$ tar xvf /var/classes/CMPS111/Spring18/Lab3.tar.gz
Build Pintos:
$ cd ~/CMPS111/Lab3/pintos/src/userprog ( note this is different to Labs 1 & 2 ) $ make
Run the first test:
$ ../utils/pintos -v -k -T 60 --qemu --filesys-size=2 \ -p build/tests/userprog/args-none -a args-none \
-- -q -f run args-none
Note “\” characters are line continuation marks and should be removed if you cut-and-paste this.
Also try:
$ make check ( runs the required functional tests - see below )
$ make grade ( tells you what grade you will get - see below )
Follow the instructions from Lab 1:
https://classes.soe.ucsc.edu/cmps111/Spring18/SECURE/CMPS111-Lab1.pdf
Background Information
(1) Pintos Calling Conventions
Pinto is a Unix-like operating system and should implement the standard Unix / C calling convention.
To understand how arguments are passed to Unix / C programs, consider the command:
/bin/ls -l foo bar
Also recall that the prototype for a C program entry point is:
int main(int argc, char *argv[])
Where argc is the number of arguments passed to the program (including the program name) and argv is an array containing pointers to each of the arguments stored as null-terminated character arrays.
To execute this program with the supplied arguments, we need to do the following:
The figure below shows the contents in the stack before executing the user program. We assume here that PHYS_BASE is 0xc0000000.

As shown above, your code should start with the stack at the very top of the user virtual address space, in the page just below virtual address PHYS_BASE ( defined in threads/vaddr.h ).
The equivalent output for the “args-none” test is as follows:

If your addresses EXACTLY match these, you are well on your way to a passing test.
(2) System Calls
Most user programs require services provided by Pintos; they access those capabilities by making system calls. To support this feature, you will need to extend the existing rudimentary system call implementation in userprog/syscall.c.
The system calls of interest in this lab are:
Note that the above descriptions are a guide only, your system calls must do whatever the tests demand they do!
The CMPS111 teaching server has GIT installed and we highly recommend you use it to track the changes you make, though this is not required.
CMPS111 is not, however, a GIT training course. But Google is your friend, so find some beginner tutorials and study them if you have never used GIT. But also remember you have friends in the shape of your classmates, the TAs, and your instructor. If you want to know how to setup and use GIT, just ask someone.
Using the GNU Debugger (GDB) with Pintos
In Lab 1 and Lab 2, many of you will have “debugged” you code using printf statements and assertions.
The code you will write in this Lab is significantly more complex and an appropriately more sophisticated mechanism for examining your code as it runs is required.
Run a test in debug node (note the new argument):
$ pintos -v -k -T 60 --qemu --filesys-size=2 \
-p build/tests/userprog/args-none -a args-none \ --gdb -- -q -f run args-none
In a separate terminal, run GDB for Pintos:
$ pintos-gdb build/kernel.o
At the prompt, connect to the running test:
(gdb) target remote localhost:1234
GDB will respond:
Remote debugging using localhost:1234
0x0000fff0 in ?? ()
From there on in, set breakpoints and step into or over functions as required.
To get the test to run to completion, enter “C” at the (gdb) prompt.
If you don't know how to use GDB, remember, Google is your friend. A quick search for “gdb tutorial C” will find you an abundance of information.
IMPORTANT: Note that these instructions only work if no-one else is using Pintos GDB at the same time. For exclusive use, you will need to install pintos on your own machine or in a virtual machine on your own machine. See Lab 2 instructions for details.
What to submit
In a command prompt:
$ cd ~/CMPS111/Lab3/pintos/src/userprog
$ make submit
This creates a gzipped tar archive named CMPS111-Lab3.tar.gz in your home directory.
UPLOAD THIS FILE TO THE APPROPRIATE CANVAS ASSIGNMENT.
In addition to submitting modified and new source files, you are required to write a short report (no more than two pages) on your work.
This report should contain at least:
If you keep a simple journal as you work your way through this lab, writing the report will be easy - it’s essentially a tidied up version of your journal.
SUBMIT YOU REPORT TO CANVAS IN THE SAME ASSIGNMENT AS YOUR CODE ARCHIVE.
Note that the report WILL NOT BE READ unless plagiarism is detected in your submission.
Requirements
User Processes:
Arguments to User Processes:
System Calls:
o read-normal o read-zero o write-normal o write-zero
o close-normal o exec-once o exec-multiple o wait-simple
Grading Scheme
The following aspects will be assessed:
IMPORTANT: Note that any solutions not using concurrency primitives for thread synchronization will get a zero on this lab. i.e. if you use any of the thread_sleep() functions in your code, you will be awarded no marks.