Computer Labs- 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 VirtualBox; 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 testing your program 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 shared directory between Minix and the host OS, i.e. under /home/lcom/labs. You should use one directory per lab assignment and a separate directory for the final project.

The main advantage of following this approach is that you will be able to use your favourite code editor, or even an IDE, in the host OS.

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:

minix$ make

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

Before executing this command, you may wisth to run:

minix$ make clean

which removes the executable as well as all the object files, i.e. the .o files. In this case, when you run make it will compile all the source files. In addition, you may also run:

minix$ make depend

which updates, or creates, the .d file of each source file of your program, if necessary. Each .d file contains a list of all the header files that are directly or indirectly included in the respective source file. This ensures that any change in one header file will trigger the recompilation of all source files which include it, directly or indirectly, when you subsequently execute make

On small projects, like those you will develop in LCOM, you can execute only:

minix$ make clean minix$ make

thus compiling all the source files of the project. For larger projects, compiling the whole project may take too much time. In this case, you may wish to execute:

minix$ make depend minix$ make

The former command, make depend, updates the .d files, or creates them, if they do not exist yet. The latter command, make, recompiles only the source files that have been modified, or that depend on header files that have been modified, and links all the project's object code files into an executable.

2.3 Configuring

Minix 3 allows an administrator to specify which kernel calls each privileged program can execute and which resources it 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, we will provide you a file with the permissions required by that lab.

For security reasons, only the system administrator, i.e. the user root, can add files to the /etc/system.conf.d/ directory using shell commands. A regular user like lcom can add files to that directory only by executing the lcom_conf utility, which takes as an argument the file to be copied to /etc/system.conf.d/. E.g., in Lab2 you shall execute the following command:

minix$ lcom_conf add ~/labs/lab2/conf/lab2

3. Program Execution

To execute a Minix 3 privileged program you need to use Minix's minix-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.

A regular user like lcom cannot execute a Minix 3 privileged program, by directly invoking minix-service. Instead, it has to use the utility lcom_run. For example, to run the privileged program lab2, without arguments, you must execute the command:

minix$ lcom_run lab2

To stop that program later you can execute the lcom_stop utility as user lcom:

minix$ lcom_stop lab2

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 service utility, you can give the command:

minix$ man service

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