CSL373: Assignment 1 on Process control and IPC
Background reading
- Read one (or more) of the following references:
- UNIX System Programming in C++ by Terrance Chan
- Beej's Guide to Unix IPC by Brian Hall
- Chapter 2 of Unix Network Programming Volume 2: Interprocess Communications by W. Richard Stevens
- Chapter 14 on Interprocess Communication of Advanced Programming in the UNIX Environment by W. Richard Stevens
- Carefully read the following man pages: signal, kill, ualarm, umask, sigprocmask,
gettimeofday, wait, exec, fork, pipe,open, ipc, clone, msgctcl, msgsnd,
msgrcf,rand, srand48.
- (optional) Read from the OS books the sections (bed time stories) that deal
with: CPU scheduling, processes, threads, IPC.
Processes
- Expand the hare and turtle process descriptions and implement IPC solutions by
defining cooperating processes.
- First use fork() and execve() to create the processes and develop
complete applications using the following Linux IPC (message passing)
mechanisms separately: (i) pipes (ii) FIFO files and (iii) message queues.
Threads
- Now, develop the same application (hare and turtle) using Linux
pthreads (shared memory). Here is a good pthreads tutorial. Notice that you have shared memory between threads so you do not need explicit communication channels. You can communicate using shared variables. However, you will need to ensure that different threads synchronize their access to shared variables to avoid inconsistencies. In particular, you should use mutexes (see tutorial) to protect all accesses to shared variables.
Tests
-
The current outcome of the race should be displayed after fixed intervals.
-
Try varying the speed and the sleeping time of the hare to see different
outcomes.
-
Compare the performance (running time) of shared memory communication
versus pipes by transferring a large amount of data between two processes
using these two mechanisms. Report your results.
-
Optionally compare the performance of other IPC mechanisms too.
Note:
- To be done individually.
- The last date of submission of solutions using pipes, FIFOs and
message Qs (processes) is Jan 11.
The last date for the threads assignment is Jan 13. The deadlines
are final and no extensions will be allowed.
- Submissions should be made through the
submit-lab1
script on palasi.
- To submit lab1, log on to palasi.cse.iitd.ernet.in, chdir into the top
directory containing the source files of your solution, and type
'submit-lab1'.
- Note that only .[chC] files will be submitted. Your submission must
have a makefile and typing 'make' in the top directory should build
your programs.
- Type '
get-submission login-id lab1
' to get a copy of your submitted files.