Computer Labs 2013/2014 - 1st Semester
LCOM's Development Process (Part 2: Development Process)


1. Introduction

In LCOM you will develop programs that interface with I/O devices at the hardware (HW) level. To facilitate this development we will use the Minix 3 operating system.

This note is the second part of a two part document on the development environment and process that you will use in LCOM. In the first document we covered the many ways you can login into Minix running on VMware Player; in this part we focus on the development process.

2. Development Process

Although the programs you will develop for Minix 3 are privileged programs, the development process you will use is, most likely, not very different from the one you have used in other programming courses. That is, first you write the code, them compile it and finally test it, by running it. Of course, we recommend that you do the development of your programs incrementally. That is, rather than executing the above sequence only after writing all the code, you should implement the functionality required for each lab gradually and test it as you implement it.

In the following paragraphs, we provide some Minix 3 specific details relative to each of the phases of the development process.

2.1 Coding

We recommend that you keep your code in the area of user lcom, e.g. in its home directory. You should use one directory per lab assignment and a separate directory for the final project.

As mentioned in the first part of these notes, we recommend that you use Eclipse with the RSE plugin, running on Linux, to edit your source files in Minix 3.

2.2 Compiling (and Linking)

In Minix, privileged user-level programs must be linked with specific libraries. To automate the process, you'll use the make utility. This is a program that makes compilation of large programs more efficient, by limiting compilation only to the source files that have been modified.

Make uses an input file, usually named Makefile or makefile, which must specify the dependencies between the program to be compiled and the modules used to build it.

We will present the make utility and Makefiles in more detail later in the course. For now, all you need to know is that in the different labs you'll use a Makefile similar to those used by most Minix 3 device drivers.

Once the Makefile has been created, compilation of your program can be achieved by giving the command:

$ make

Note that $ is the default shell prompt for a non-root user. That is, you should compile your program as user lcom.

2.3 Configuring

Minix 3 allows an administrator to specify which kernel calls privileged programs can execute and which resources they can access in those calls. The permissions of a privileged program are specified in a file with that program's name in the /etc/system.conf.d/ directory. For each lab, you will be given the permissions required by your program, and you will have to create the corresponding file.

For security reasons, only the system administrator, i.e. the user root, can add files to the /etc/system.conf.d/ directory. To become root, you can log in as user root. Alternatively, you can execute the su command as follows:

$ su

assuming that you have previously logged in as user lcom.

3. Program Execution

To execute a Minix 3 privileged program you need to use Minix's service utility. This program parses the permissions file in the directory /etc/system.conf.d/ to determine the permissions that the privileged program should have, and requests the resurrection server (RS) to create a process that is given those permissions and that executes the privileged program specified.

For example, to run the privileged program lab1, which takes no arguments, and is in directory /home/lcom/lab1/ you must execute the command:

# service run /home/lcom/lab1/lab1

Note that # is the shell prompt for the root user. That is, to run a privileged program in Minix, you must be logged in as user root. Furthermore, you must give service the full path name of your privileged program. However, if you are in the directory of your privileged program, you can use the ability of the shell of replacing a command by its output, by specifying your program between two ` chars. For example, if you are in the directory /home/lcom/lab1/ and you want to execute a privileged program in that directory whose name is lab1, you can execute the command:

# service run `pwd`/lab1

To stop that program later you can execute the command:

# service stop lab1

That is, to stop a privileged program you must give its name, not its absolute path.

4. Further Reading

In Minix 3, like in all Unix-like system, you can get on-line help about almost any command available by means of the man utility. For example, to learn how to use the su utility, you can give the command:

$ man su

You can also find on Minix 3's site some resources that can help you using better Minix 3. The following are some starting points that may be useful: