Exercise 1: Message logging
Introduction
The MINIX operating system is a message passing system in which messages are
sent between processes (tasks, servers, and user processes). For this exercise
you have to keep a log of messages which MINIX exchanges among the various
processes. For each message its source, destination, and time stamp (time
of occurrence) are kept. The last 4096 messages sent should be available by
reading from the ``/dev/msglog'' device. A user program to view the
message log should also be written.
Assignment and hints
You have to modify the kernel to keep track of the messages. You should
implement the message log (``/dev/msglog'') device as described in
in its manual msglog(4). The auxiliary
program which displays the logged messages is described in its manual
msglog(1).
-
Keep the required information of the last 4096 messages sent by
the system.
-
Make sure your msglog(1) user
program is efficient, and does not generate too many messages itself!
These will clutter up the log.
-
When the user program msglog(1)
receives as argument a request to read more than 4096
messages, its behaviour is undefined. However, the implemented behaviour
should be reasonable.
-
You should implement ``/dev/msglog'' as a memory device,
with major device number 1 and minor device number 5.
Relevant information can be found in the OS book in sections: 2.5,
2.6 (excluding 2.6.5-7 and 9-11), 3.4-6, and 5.6.9-10.
Check at least the index for the following references:
- (UNIX) Special files
- Major/minor numbers
- Device drivers
- Tasks
- Signals
- MINIX system call: alarm
- MINIX system call: mknod
Testing
The following are some suggested tests. Your code should pass these tests to
get a grade at all.
- Count the number of messages exchanged during an ``ls -l /dev/null''.
- Count the number of messages exchanged during an``cat /etc/passwd > /dev/null''.
Review the source code, and count the number of messages sent between the
various processes and tasks during a system call. The theoretical amount of
messages sent is obtained by adding the messages sent by the system calls
used in the user program above (i.e. ls and cat). You should
check that at least the theoretical number of messages are logged, in both
cases described above. Extra messages showing up in the log, in the form of
interrupts or other processes, is hard to prevent.
It is probably not enough to use only your user program to test the exercise.
You should probably also write separate testing tools to test your code.
Manual pages
- msglog(1)
- display the Minix message logs
- mknod(2)
- mknod system call
- msglog(4)
- message log device
- mknod(8)
- create special files
Bits and pieces
- minix/logent.h
- Header file with log entry definitions