||Operating Systems Labs|
Lab given for distance course spring 99, TF spring 99, MNP
fall 99, MNP spring 2000, distance course spring 2001, MNP spring
2001, distance course spring 2002, MNP spring 2003.
The lab is designed to be run on the system (DoCS). There are 3 lab
sessions and the lab is divided into 3 parts: process management,
process synchronisation, and file system. To run the lab on a Linux
machine (or another unix based machine outside DoCS), you should get
To run the lab locally on DoCS, you will need
this other package.
The lab sessions are:
- Process management:
Introduction to processes, the ps command, the fork() function, and
process communication with pipes. Assignment
Note on exercise 2: your program should create 4 or 5 processes
that run at the same time, and then it should wait for them. It is not
interesting to create/wait four times and then have only one son
running at a time. This is important for exercise 3. The important
point about exercise 2 is to understand that processes run in
parallel using the same code. Note on exercise 3: you
have to use three processes, one which creates the pipe and spawns the
producer process and the consumer process. Close the pipe when you do
not need it. Print out messages on what is going on.
It is asked to deal with the case when either the consumer or the producer
finishes first without the use of a particuliar message. You are allowed
to use a special message from the producer if you have a problem.
Note on exercise 3: do not forget that you are sending raw data
though your pipe between the producer and the consumer. You have to code
in some way, or to mark that a word is sent, not only an unknown sequence
of bytes. To do this you may think about using special characters to mark
the beginning or the end (or both) of a word, or you may send in some coding
(up to you) the size of your word. Think about your pipe as a file : you
have just a sequence of characters and you need some encoding to be able
to read it.
- Process synchronisation:
Use of shared memory and semaphores as mutexes or means of
- File system:
The df, ls, and ln commands; inodes, files,
directories etc.. in UNIX. Assignment
How to compile
How to handle command line arguments
C standard library (short)
How to handle errors
from the course book (UNIX slides from the book "Operating System
Concepts" by Silberschatz and Galvin).
A sample on how to create semaphores and shared memory.
The source of ipc-create available on
The source of pencils.c.
The C-source and
C++ version of the simple shell presented
at the lab introduction. For those who can not think in C, here is a special version in C++ with a
Process class to be extended for your own processes. If you
choose to use this class for exercise 3 of lab 1 or later , I expect
good explanations on how it works. You may use this class in order to
understand how fork() works, if it helps you. However, you are not
allowed to use it for the exercise 2 of the first lab because you
have to use fork() explicitely on your own, as described in exercise 2.