The University of Queensland Homepage
School of ITEE ITEE Main Website

 COMP3301 Prac 5

The Minix process manager

This prac will let you explore how the Minix process manager works.  This includes the working of the system calls handled by the process manager (fork, exec and others).

Servers under Minix 3

The process manager is run as a server.  This means it sits between the user processes and the kernel, providing a specified set of services.  Once compiled the process manager looks like a conventional executable file.  So how does it end up having the special privileges of a server?

  • The pm is loaded as part of the boot image.  Some of the details of the boot image are defined in kernel/table.c.  Have a look at this file and find where the process manager (and other servers, like the file system) are defined and assigned privileges.

  • What kernel calls is the process manager allowed to make?  Why is it allowed to make these calls?

The program service may be used to start and stop servers once the system is booted.  The process manager is an essential part of the operating system, so service is not used to start or stop it.

The process manager source

The process manager is structured in a very similar way to the device drivers examined in Prac 4:

  1. initialization

  2. infinite loop involving:

    1. get work

    2. perform the work

    3. reply

  • Within servers/pm/main.c, find each of the steps described above - identify which functions are involved in each.

Initialization is the most complex of the steps.  The code is at times difficult to follow.  Use the following questions as a guide to help you understand the pm_init function:

  • A number of structs are declared at the start of the function.  Find out how each of them is defined.  (You may have to do some searching in relevant files!)

  • The process table is initialized - what is actually done here?

  • Find out what the functions sigemptyset and sigaddset do.  What does this part of the initialization achieve?

  • Kernel information is retrieved using some kernel calls.  Work out what calls are actually used and what they achieve.

  • The process table is initialized.  What tasks are initialized here?  What is done to each task?

  • mem_init is called to initialize the hole list - where does the information about the physical memory come from?

System calls

The main loop of the program implements the main functionality of the process manager.

  • How does get_work actually work?  What does it do?

  • Once work has been obtained (through some other process requesting it), some checking is done before the work is implemented.  This is done through an indirect function call, as we saw with interrupt handlers.  Find where the functions are assigned to each system call number (Hint: this is part of the kernel).

  • Use the fork system call as an example to examine.  Within both kernel/system/do_fork.c and servers/pm/forkexit.c, there is a do_fork() function.  Which one is used to implement the fork system call?  If both are used, find out how they are both called and in what order they happen.

Signals

Signals allow the kernel to interrupt a running user process. 

  • What signals are defined?  Where are they defined?  Have a look at pm/signal.c and include/signal.h for some details.

  • What system calls does a process use to change it's handling of signals?  These are provided by the process manager - have a look at pm/signal.c for details.

Summary

The Minix process manager runs as a process with conventional user privileges, completely separate from the kernel.  This allows more code to be executed in user space leaving less potential bugs running in kernel space.  The process manager performs those parts of the system calls which do not require specific privileges which only the kernel should have.  These services are provided by the system task through the conventional message passing mechanism.