Göm menyn
IT-Programmet, Tema 1 i termin 4:

TTIT61 Processprogrammering och Operativ System

/Concurrent Programming and Operating Systems/


Lab 0 - Pintos: Introduction and installation:

Pintos is an instructional operating system that runs on x86 machines. You will run it in QEMU -- a computer system emulator, which runs as a user process under UNIX. Pintos is written in C. The lab assignments require modification of the provided version of Pintos by adding functionality to parts of it, for instance, synchronization of threads and memory management.

Installation

First, set up necessary modules and paths by running the following commands:

        module initadd ~TTIT61/labs/modules/pintos
and
        module add ~TTIT61/labs/modules/pintos
Then, you will need to copy the Pintos files to your account on the IDA Sun workstations. Run the following command in a shell to install them in a sub-directory called pintos of your current directory:

        gzip -cd ~TTIT61/labs/pintos_ida.tar.gz | tar xvf -

 

Now you have the following (partially shown) path structure:

        pintos/src
            devices
            examples
            filesys
            lib
            misc
            tests
            threads
            userprog
            utils
            vm

Primarilly you will work in threads and userprog directories.

Compilation

 

To compile Pintos for the first time, change your current directory to the threads directory (cd pintos/src/threads) and issue the command:

        gmake

This will create build sub-directory under threads directory with a version of Pintos ready to run in a simulator. A more detailed description of what is created in build directory during this step can be found here

Go down to the build directory and start Pintos to see that it runs:

   cd build
   pintos --qemu -- run alarm-multiple 
You should get a new window with an output that ends with something similar to the following:
astmatix <313> pintos --qemu -- run alarm-multiple
Writing command line to /tmp/rCAZSDplHd.dsk...
qemu -hda /tmp/rCAZSDplHd.dsk -m 4 -net none -nographic -monitor null
Kernel command line: run alarm-multiple
Pintos booting with 4,096 kB RAM...
374 pages available in kernel pool.
374 pages available in user pool.
Calibrating timer...  2,454,400 loops/s.
Boot complete.
Executing 'alarm-multiple':
(alarm-multiple) begin
(alarm-multiple) Creating 5 threads to sleep 7 times each.
(alarm-multiple) Thread 0 sleeps 10 ticks each time,
(alarm-multiple) thread 1 sleeps 20 ticks each time, and so on.
(alarm-multiple) If successful, product of iteration count and
(alarm-multiple) sleep duration will appear in nondescending order.
(alarm-multiple) thread 0: duration=10, iteration=1, product=10
(alarm-multiple) thread 1: duration=20, iteration=1, product=20
(alarm-multiple) thread 0: duration=10, iteration=2, product=20
(alarm-multiple) thread 0: duration=10, iteration=3, product=30
(alarm-multiple) thread 2: duration=30, iteration=1, product=30
(alarm-multiple) thread 0: duration=10, iteration=4, product=40
(alarm-multiple) thread 1: duration=20, iteration=2, product=40
(alarm-multiple) thread 3: duration=40, iteration=1, product=40
(alarm-multiple) thread 0: duration=10, iteration=5, product=50
(alarm-multiple) thread 4: duration=50, iteration=1, product=50
(alarm-multiple) thread 0: duration=10, iteration=6, product=60
(alarm-multiple) thread 1: duration=20, iteration=3, product=60
(alarm-multiple) thread 2: duration=30, iteration=2, product=60
(alarm-multiple) thread 0: duration=10, iteration=7, product=70
(alarm-multiple) thread 1: duration=20, iteration=4, product=80
(alarm-multiple) thread 3: duration=40, iteration=2, product=80
(alarm-multiple) thread 2: duration=30, iteration=3, product=90
(alarm-multiple) thread 4: duration=50, iteration=2, product=100
(alarm-multiple) thread 1: duration=20, iteration=5, product=100
(alarm-multiple) thread 3: duration=40, iteration=3, product=120
(alarm-multiple) thread 1: duration=20, iteration=6, product=120
(alarm-multiple) thread 2: duration=30, iteration=4, product=120
(alarm-multiple) thread 1: duration=20, iteration=7, product=140
(alarm-multiple) thread 2: duration=30, iteration=5, product=150
(alarm-multiple) thread 4: duration=50, iteration=3, product=150
(alarm-multiple) thread 3: duration=40, iteration=4, product=160
(alarm-multiple) thread 2: duration=30, iteration=6, product=180
(alarm-multiple) thread 3: duration=40, iteration=5, product=200
(alarm-multiple) thread 4: duration=50, iteration=4, product=200
(alarm-multiple) thread 2: duration=30, iteration=7, product=210
(alarm-multiple) thread 3: duration=40, iteration=6, product=240
(alarm-multiple) thread 4: duration=50, iteration=5, product=250
(alarm-multiple) thread 3: duration=40, iteration=7, product=280
(alarm-multiple) thread 4: duration=50, iteration=6, product=300
(alarm-multiple) thread 4: duration=50, iteration=7, product=350
(alarm-multiple) end
Execution of 'alarm-multiple' complete.

After that, you can stop the emulator by Ctrl+C combination or by closing the simulator window. After you change some files you will re-compile the local version of pintos that exists in the current working directory (which will be threads or userprog depending on the lab), using the command gmake. To explore available options when starting Pintos run pintos without any arguments.

Debugging

The lab assignments are hard to debug without a debugger, in fact, in order to get help from the lab assistants you will have to use one. There is a debugger called "ddd" available which works fine with Pintos. It is a graphical interface on top of the "gdb" (the GNU debugger).

To debug with DDD:

  1. run 'pintos --qemu --gdb -- run alarm-single'
  2. run 'ddd --gdb --debugger pintos-gdb kernel.o&' in another terminal window.
  3. execute command debugpintos in the GDB console inside DDD (the bottom frame inside DDD window)
  4. start debugging! (Begin by clicking cont in the ddd window.)
Note, that all commands are supposed to run from the threads/build directory. Afterwards you can use DDD to set up brakepoints and continue execution until a breakepoint or until you press Ctrl+C inside DDD.

Since few groups can be working on the same server, it might be a problem to use the same default port (1234) for debugging. Follow the instructions below to avoid this problem:

  1. run 'pintos --qemu --gdb --dport=port_number -- run alarm-single' and set port_number to 1234 + k, where k is your group number in WebReg
  2. run 'ddd --gdb --debugger pintos-gdb kernel.o&' in another terminal window.
  3. execute command target remote localhost:port_number in the GDB console inside DDD (the bottom frame inside DDD window)

Try to to open and use debugger to make sure that it works.

Documentation

The most extensive information information available to you about Pintos can be found here.

Hint: There is a lot of useful information to find in the comments of various .c and .h files. Read them!

Next Laboratory work

Laboratory Assignment 1 in which you will learn the basics of synchronization

TTIT61
Temamål
Temaplan
Schema
Examination
Referenslitteratur
Personal
Register for labs

Föreläsningarna
Programexempel
Forum
Labresultat

Schemaläggning
Kritiska sektioner
Processorstöd för operativsystem
Sekundärminne
UNIX, WinNT
Säkerhet

Intro: C/make
Intro: installation
Threads and synchronisation
System calls
Execution of user programs
File system

Lesson 1
Lesson 2
Lesson 3

C/C++ OH
C/C++ tutorial
C pointers tutorial
Pintos documentation
Memory Issues in Pintos
Pintos on-line documentation
The gnu DDD documentation
DDD tutorial
Debugging topics
Programing with threads

Guidelines for writine and changing source code
Pintos source code

Sidansvarig: Sergiu Rafiliu
Senast uppdaterad: 2011-09-12