Foreword
The following exercises needs for you to access a Unix system. A Linux
operating system would be better (because I didn't try these exercises
on Solaris) but probably not mandatory.
The lecture last week was extremely uncomplete. I will hold some
complements on the beginning of the lecture of the 26/04/2005. Look at
the new slides for making the exercices.
1. ipcs
& ipcrm
- Read the man pages for these two commands.
- If running
ipcs
show you some already existing IPC,
try to identify the program who created it (use ipcs
-p
).
2. Semaphores
- Read the manual page for
man sem.h.
- Try out the examples on the slides.
- Make a critical section that can cope with 2 users maximum and no
more. Create 6 clients process which are sleeping for a random amount
of seconds and then trying to access the critical section.
3. Message Queue
- Read the manual page for
man msg.h
- Try out the examples on the slides.
- Make one process listening to keyboard events with
fgets
which is sending the key pressed to another process
through messages to print it out.
4. Shared Memory
- Read the manual page for
man shm.h
- Try out the examples on the slides.
- Do the same than exercise 3, not with a message queue but shared
memory (don't forget to protect the access in read/write with
semaphores).