CEG 433/633: Operating Systems

P2: Processes and IPC Mechanisms

Download P2.tbz
   

This is Part 2 of the project for this term.  This part deals with a new topic: Processes.  This will be merged with FileSys in P4.   Our goals in this part of the project is  to (i) understand process creation and control, (ii) learn different inter process communication (IPC) mechanisms.

Do not use source code files of others or even those of mine but from prior terms.  The Project Expectations are all still applicable.

Be Considerate. Do make sure that you are not using up too much space (say > 10 MB) in your home directory.  The following will show your disk space usage:  du -s ~

Processes

The project constructs a simple data flow network where each node is a binary arithmetic operator.   E.g., the expression ((a+(b*(a+c)))/d) represents the network:

in a------------\
in b-------\     + --\
in a--\     * --/     \
       + --/           / ---- out
in c--/               /
in d-----------------/

which contains ten processes: 5 in, 1 out, 2 plus, 1 mult, 1 div.

All "in", "+", ...-processes behave as follows.  For complete understanding, you must digest the source code of the processes. The "in a" process opens the file named "a".  This is a file of text with one integer per line.  The in process reads-in one 4-byte integer, and "outputs" it.  The "+"-process uses descriptors 3 and 4 as inputs, and 5 as its output descriptor.  So, e.g., the second "+"-process (i.e., the plus of (a+c)) receives one integer from the output of "in a" piped into 3 and another from "in c" piped into 4, adds these two numbers and outputs the result to 5, which will be pipe-connected to the "*"-process.

P2.tbz

Download the P2.tbz. It contains a concurrent program that hooks several processes up, using pipes, according to a one-line text description. The description is a fully parenthesized arithmetic expression, with no white chars, where each identifier is one letter. Each letter represents a file with that name which contains a sequence of integers, in decimal form, one per line ending with a 0.

Enhancements

Make the improvements described below.  Wherever explanations are asked for, include your answers in ReadMe.txt.  You will need to study thoroughly all of the source code of P2.tbz expect perhaps that of draw.cpp.

  1. File main.cpp contains the declaration static char fnm[2]; Make this a non-static local declaration. What changes are necessary where?
  2. A control-C should terminate a network (i.e., all child processes are terminated) but not the parent driver. Note that the driver terminates if it receives an illegal description.
  3. P2 prints the prompt exp: `too soon.' Modify P2 so that the prompt appears only after all children processes have terminated. Explain the modifications you have made.
  4. Integrate the drawing package given in file draw.c with the rest of the project. Use shared memory to communicate with the display process. Document the changes you made. Explain the integration.
  5. As is, our processes (except for out) do not show us the outputs they produce on descriptor 5.  Design a new process named show5 that does this.  Use shared memory.
  6. We cannot assume that the sigle-letter named files all contain the same number of numbers.  Modify the code of the operator processes so that if one prong is out of numbers a default number is substituted.

Submissions

All submissions must be done in the OSIS Lab using the turnin program. We will be running your programs on the machines in OSIS Lab only.  The command to use for this part looks like this:

/home/ceg433/ceg43300/bin/turnin P2 names-of-files-you-wish-to-submit


Grading Sheet for P2:  Processes and IPC
CEG 433/633: Operating Systems

Instructor = Prabhaker Mateti
Grader = Greg Aselage
Weight 5%
Extra credit points are awarded in recognition of good work and extra work, in addition to the max possible points.  Quality is subjectively judged.  Merely turning in a file will not receive full score.  Some items have a cascading effect.
Student OSIS Login ID Bonus Points
Item description Max Points
P2 continues to build without warnings or errors, and continues to work as before 10  
static char fnm[2] 10  
A control-C should terminate a network 10  
Integrate the drawing package given in file draw.c 20 -------
Design a new process named show5 30  
If one prong is out of numbers a default number is substituted. 20  
Late submission: minus 2% per day late; Not accepted at all after 4 days -8  
Files were not submitted using turnin program = minus 10 points -10  
Total 80  
 
Copyright © 2009 pmateti@wright.edu